Ios tableview返回错误(数据源必须返回单元格)
我正在尝试将我的应用程序更新到iOS 7,但分配的内容消失或不再工作:S 我不能解决这个问题,我不知道为什么它返回空值Ios tableview返回错误(数据源必须返回单元格),ios,uitableview,ios7,Ios,Uitableview,Ios7,我正在尝试将我的应用程序更新到iOS 7,但分配的内容消失或不再工作:S 我不能解决这个问题,我不知道为什么它返回空值 *** Assertion failure in -[UITableView _createPreparedCellForGlobalRow:withIndexPath:], /SourceCache/UIKit_Sim/UIKit-1914.84/UITableView.m:6061 *** Terminating app due to uncaught exception
*** Assertion failure in -[UITableView _createPreparedCellForGlobalRow:withIndexPath:], /SourceCache/UIKit_Sim/UIKit-1914.84/UITableView.m:6061
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"Cell";
static NSString *cellIdentifier2 = @"Cell2";
NSDictionary *naamInfo;
if (tableView == self.searchDisplayController.searchResultsTableView) {
naamInfo = [self.filteredNameArray objectAtIndex:indexPath.row];
} else {
naamInfo = [self.nameList objectAtIndex:indexPath.row];
}
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if ([[naamInfo objectForKey:@"gender" ] isEqual: @"man"] ) {
cell = [UITableViewCell configureFlatCellWithColor:[UIColor peterRiverColor] selectedColor:[UIColor cloudsColor] reuseIdentifier:cellIdentifier inTableView:tableView];
}else if ([[naamInfo objectForKey:@"gender" ] isEqual: @"woman"]){
cell = [UITableViewCell configureFlatCellWithColor:[UIColor colorWithRed:1 green:0.396 blue:0.604 alpha:1] selectedColor:[UIColor cloudsColor] reuseIdentifier:cellIdentifier2 inTableView:tableView];
}
NSLog(@"CELL %@",cell);
cell.detailTextLabel.font = [UIFont boldFlatFontOfSize:14];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.cornerRadius = 8.f;
cell.separatorHeight = 1.f;
cell.textLabel.font = [UIFont boldFlatFontOfSize:18];
cell.textLabel.text = [naamInfo objectForKey:@"name"];
cell.detailTextLabel.text = [naamInfo objectForKey:@"country"];
return cell;
}
日志返回空值,因此我了解为什么会出现异常,但我不知道如何解决此问题?尝试放置:
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
之后:
UITableViewCell *cell = [tableView dequeue....
还是同样的问题:如果你使用的是情节串连板,请检查文件的所有者是否是你的tableVieController,以及单元格是否正确设置。我检查了它,我恢复到旧的库,它再次工作,有些东西坏了,在我配置Flat等后,它会使单元格为nill。。。谢谢你的帮助:)