具有自定义UITableViewCell的UITableViewController [英] UITableViewController with custom UITableViewCell
问题描述
我很好奇为什么在控制器上自定义表格单元格时会出现SIGABRT错误.该单元格是在 UITableViewCell
类中创建的,所有链接都可以看到. UITableViewController
不是rootController,而是另一个 UITableViewController
的根控制器.所以RootView-> TableViewCont->此TableViewCont.
I was curious why I would be getting a SIGABRT error when I am customizing a tableview cell on a controller. The Cell is created in a UITableViewCell
class everything is linked that I can see. The UITableViewController
is not the rootController but a controller off the root off another UITableViewController
. so RootView -> TableViewCont -> This 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日志中的错误:
This is the error in the gdb log:
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<DemoViews 0x6b16ce0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key cellDescription.
推荐答案
我遇到了同样的问题,但不明白为什么要使用SIGABRT.但是我解决了这个问题:
I had the same issue and did not understand why I am getting SIGABRT. However I resolved the problem:
- 首先将您的单元格布局放置在单独的xib中.不要问为什么,如果xib中还有其他东西,那就行不通了.
- 现在,您可以按照 查看全文