- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"CustomCell";
CustomCell *cell = (CustomCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
}
[email protected]"date";
cell.cellDescription.text [email protected]"Description";
cell.cellImageview.image = [UIImage imageNamed:@"sample.png"];
cell.cellTitle.text = @"Title";
NSLog([cell Description]);
return cell;
}我想创建CustomCell但它给一些错误,如何解决它?错误描述如下
NSLog([cell Description]);
返回null
以上就是我的方法它提供了以下错误: 这里
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'UITableView dataSource must return a cell from tableView:cellForRowAtIndexPath:'
分配您的自定义单元格里面如果(细胞==零){} – NANNAV 2013-04-05 09:24:26
什么@vitality正显示出你是正确的。底线是你需要初始化一个新的细胞。因此,在'(cell == nil)'之后,只需插入以下这行:'cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];' – Lefteris 2013-04-05 09:25:22