UITableViewCell错误 - 此类不是密钥值编码兼容的密钥

sam*_*max 7 iphone cocoa-touch objective-c cocoa-bindings ios

当我尝试通过UINib的instantiateWithOwner方法从xib文件加载自定义UITableViewCell时,我收到以下错误.我已经尝试了所有其他解决方案,我可以在这里找到没有运气.问题似乎是当Uibib打开xib文件时,它使用超类UITableViewCell而不是我的自定义类ContentPackCell.我附上了Interface Builder的截图,显示了我将xib与我的类相关联的位置以及关联标识符的位置.我必须要做一些其他的步骤.

错误:

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UITableViewCell 0x6b87220> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key descriptionLabel.'

代码(类似于Apple的示例AdvancedTableViewCells项目):

ContentPackCell *cell = (ContentPackCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
    [self.cellNib instantiateWithOwner:self options:nil];
    cell = tmpCell;
    self.tmpCell = nil;
}
Run Code Online (Sandbox Code Playgroud)

在IB中设置自定义类

在IB中设置标识符


更新:

设置文件所有者的类

Bin*_*man 36

确保nib中的File's Owner设置为NSObject,并确保没有连接到File's Owner的出口.

  • 在经历了很多相关的问题后,这就解决了我的问题. (2认同)

App*_*ker 5

检查笔尖中的所有元素,确保它们不引用不再存在的元素.右键单击它们以查看指向什么的内容.那里肯定会有东西.


E. *_*ers 2

看起来您已将笔尖中的 UILabel 与代码中不再存在的 IBOutlet 链接起来(descriptionLabel)。

所以再次检查你的 nib 文件。我也多次遇到此错误,这对我来说是解决方案。