- (UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0) {
[_tableView registerClass:[GraphicsTableViewCell class] forCellReuseIdentifier:kQuotaDetailVc_Graphics_Cell];
GraphicsTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kQuotaDetailVc_Graphics_Cell forIndexPath:indexPath];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.backgroundColor = [UIColor whiteColor];
cell.delegate = self;
cell.cellFrame = _cellFrameArray[indexPath.section];
cell.graphicsStyle = self.graphicsStyle;
return cell;
} else if (indexPath.section == 1) {
[_tableView registerClass:[QuotaDetailTableViewCell class] forCellReuseIdentifier:kQuotaDetailVc_CellDetail_Cell];
QuotaDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kQuotaDetailVc_CellDetail_Cell forIndexPath:indexPath];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.backgroundColor = [UIColor whiteColor];
cell.cellFrame = _cellFrameArray[indexPath.section];
return cell;
} else {
[_tableView registerClass:[QuotaCompareTableViewCell class] forCellReuseIdentifier:kQuotaDetailVc_Compare_Cell];
QuotaCompareTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:kQuotaDetailVc_Compare_Cell forIndexPath:indexPath];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.cellFrame = _cellFrameArray[indexPath.section];
cell.backgroundColor = [UIColor whiteColor];
return cell;
}
}
{
CGRect frame = CGRectMake(0, 0, ScreenWidth, ScreenHeight - TabBarHeight - ViewCtrlTopBarHeight);
_tableView = [[UITableView alloc] initWithFrame:frame style:UITableViewStyleGrouped];
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
_tableView.delegate = self;
_tableView.dataSource = self;
_tableView.scrollEnabled = NO;
_tableView.backgroundColor = [UIColor whiteColor];
[self.view addSubview:_tableView];
}
上面的是cellForRow里面的写法,
下面是创建tableview的时候写法,
我这里崩溃的日志是
*** Assertion failure in -[UITableView _configureCellForDisplay:forIndexPath:], /SourceCache/UIKit/UIKit-3318.93/UITableView.m:7344
我就没理解怎么就奔溃在tableview的cellForRow方法里面了,cell明明都返回了,
[tableView dequeueReusableCellWithIdentifier:......] 这三个调用,如果有返回空值,程序就会crash。