我很好奇,为什么我会在控制器上定制tableview单元格时遇到SIGABRT错误。单元格创建于UITableViewCell
类,所有链接都可以看到。 UITableViewController
不是根控制器,而是另一个根关闭的控制器UITableViewController
。所以RootView - > TableViewCont - >这个TableViewCont。UITableViewController与自定义UITableViewCell
的错误是在cellForRowAtIndexPath
功能:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:
(NSIndexPath *)indexPath{
static NSString *CellIdentifier = @"CellTest";
CellTest *cell = (CellTest *)
[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *topLevelObjects = [[NSBundle mainBundle]
loadNibNamed:@"CellTest" owner:self
options:nil];//**error is thrown here**//
for(id currentObject in topLevelObjects){
if([currentObject isKindOfClass:[UITableViewCell class]]){
cell = (CellTest *) currentObject;
break;
}
}
}
// Configure the cell...
cell.cellTitle.text = @"Test";
cell.cellDescription.text = @"little detail";
return cell;
}
这是在gdb的日志中的错误:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<DemoViews 0x6b16ce0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key cellDescription.
你确定你已经包括了一切吗?尝试清理项目。我在我的应用程序中有相同的代码,它的功能就像一个魅力... – fbernardo 2012-03-02 20:46:06
它说,一切都很干净。它有什么不同,具有该表的文件只是一个不是根的UITableViewController,Cell代码只是一个UITableViewCell。我需要向UITableViewController的.xib添加任何内容 – Rob 2012-03-02 20:55:43
xib中的这一定是奇怪的。 UITableViewCell的“自定义类”是否设置正确?它默认是'UITableViewCell',但你可能需要它成为'CellTest'。 – gregheo 2012-03-02 21:13:33