.xib ファイルを開いています。このファイルには.xib ファイルが含まれUITableView
てUIPopViewController
いますUIATableView
。
しかし、cellForRowAtIndexPath メソッドを呼び出した後、アプリがクラッシュします。
私のコードは次のとおりです。
- (IBAction)btnOilChangePressed:(id)sender {
OilChangeView *oilVC = [[OilChangeView alloc] initWithNibName:@"OilChangeView" bundle:nil];
UIPopoverController *popView = [[UIPopoverController alloc] initWithContentViewController:oilVC];
[popView setPopoverContentSize:CGSizeMake(480, 250)];
[popView presentPopoverFromRect:btnOilChange.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionLeft animated:YES];
}
以下は OilChangeView.m ファイルのコードです
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [arrayInfo count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
cell.textLabel.text = [arrayInfo objectAtIndex:indexPath.row];
NSLog(@"text:%@",[arrayInfo objectAtIndex:indexPath.row]);
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
// Configure the cell...
return cell;
}