问题
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.
The error is in the cellForRowAtIndexPath
function:
- (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;
}
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.
回答1:
I had the same issue and did not understand why I am getting SIGABRT. However I resolved the problem:
- First place the layout of your cell into a separate xib. Don't ask why, it just doesn't work if there're other things in the xib.
- Now you can follow the recipe of Apple for creating custom cells.
来源:https://stackoverflow.com/questions/9539960/uitableviewcontroller-with-custom-uitableviewcell