我试图做一个基本的自定义单元格,并在我跟着教程后,我得到了这个问题。UITableView数据源问题
reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
- (NSInteger)numberOfSections;
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [array1 count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"MainCell";
CustomCell *customCell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
/*if (! customCell) {
NSArray *parts = [[NSBundle mainBundle] loadNibNamed:@"cell" owner:nil options:nil];
customCell = [parts objectAtIndex:0];
}
*/
customCell.lblTime.text = [array1 objectAtIndex:indexPath.row];
customCell.lblEvent.text = [array2 objectAtIndex:indexPath.row];
return customCell;
}
而且我已经设置在的tableView身份但仍不能正常工作,我用故事板。此外,我已经链接了datasource
和delegate
。请问哪里是我的问题?
您是否尝试过打破了'的cellForRowAtIndexPath:'方法,看是否customCell是零之后调用中退出? – Jonathan 2014-10-20 14:13:52
请检查您的单元格是静态的还是动态的,并检查您的.m委托类中的段和行是否给出了正确的编号 – 2014-10-20 14:14:56
@Jonathan我现在检查了customCell是否为零。我该怎么办? – CAN 2014-10-20 14:15:57