なぜコントローラー上のテーブルビューセルをカスタマイズしているときにSIGABRTエラーが発生するのか不思議でした。 Cellは、UITableViewCell
クラスで作成され、すべてがリンクされています。 UITableViewController
はrootControllerではなく、別のコントローラから離れたコントローラUITableViewController
です。ので、RootView - > TableViewCont - >このTableViewCont。カスタムUITableViewCellを持つUITableViewController
エラーが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
それはすべてがきれいだと言います。それは、テーブルを持っているファイルがルートではなく、CellコードがちょうどUITableViewCellであるUITableViewControllerであるという違いを生じさせるでしょうか? UITableViewControllerの.xibに何かを追加する必要がありますか – Rob
xibには何か変わったことがあります。 UITableViewCellの「カスタムクラス」は正しく設定されていますか?デフォルトでは 'UITableViewCell'ですが、おそらく' CellTest'が必要です。 – gregheo