【发布时间】:2012-03-02 20:33:41
【问题描述】:
我很好奇为什么在控制器上自定义表格视图单元格时会收到 SIGABRT 错误。 Cell 是在UITableViewCell 类中创建的,我可以看到所有内容都已链接。 UITableViewController 不是 rootController,而是另一个 UITableViewController 的根控制器。所以 RootView -> TableViewCont -> 这个 TableViewCont。
错误在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.
【问题讨论】:
-
您确定您已包含所有内容吗?尝试清理项目。我的应用程序中有相同的代码,它的工作就像一个魅力......
-
它说一切都很干净。具有表的文件只是一个不是根的 UITableViewController 并且 Cell 代码只是一个 UITableViewCell 是否会有所不同。我是否必须在 UITableViewController 的 .xib 中添加任何内容
-
xib 里一定有什么奇怪的东西。 UITableViewCell 的“自定义类”是否设置正确?默认为
UITableViewCell,但您可能需要它为CellTest。 -
类在CellTest.xib中设置为CellTest
-
文件CellTest.xib的文件所有者是CellTest?它应该...
标签: ios uitableview customization