当我尝试通过UINib的instantiateWithOwner方法从xib文件中加载自定义的UITableViewCell时,出现以下错误。我已经尝试了这里找到的所有其他解决方案,但都没有成功。问题似乎在于当UINib打开xib文件时,它使用超类UITableViewCell而不是我的自定义类ContentPackCell。我已经附上了一个来自Interface Builder的屏幕截图,显示了我将xib与我的类以及标识符相关联的位置。一定有些步骤我遗漏了。
错误信息:
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key descriptionLabel.'
代码(类似于苹果的示例AdvancedTableViewCells项目):
错误信息:
*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key descriptionLabel.'
代码(类似于苹果的示例AdvancedTableViewCells项目):
ContentPackCell *cell = (ContentPackCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
[self.cellNib instantiateWithOwner:self options:nil];
cell = tmpCell;
self.tmpCell = nil;
}
更新: