我正在尝试在 UIViewController 上显示自定义 TableView,但收到错误消息“UITableView dataSource 必须从 tableView:cellForRowAtIndexPath 返回一个单元格:”
我已将 TableView 连接到数据源和委托。
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Custom";
Custom *cell = (Custom *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
NSArray *topLevelObjects = [[NSBundle mainBundle]loadNibNamed:@"Custom" owner:self options:nil];
for (id currentObject in topLevelObjects)
{
if ([currentObject isKindOfClass:[Custom class]])
{
cell = (Custom *) currentObject;
break;
}
}
}
cell.textLabel.text =[arr objectAtIndex:indexPath.row];
请帮忙