所以我不确定这里发生了什么,但在 iOS 6 之前,使用 Storyboard,我会这样做来创建一个 UITableViewCell 子类。
1) UITableViewCell 子类 .h 和 .m 为我的商店创建。 2) 在 Storyboard的 ViewController 上创建的自定义 UITableViewCell。将其标识更改为自定义 UITableViewCell。给它重用标识符名称。
然后当我想实例化单元格时,在 ViewController 的类中,在
static NSString *TotalDistanceCellIdentifier = @"TotalDistanceCellIdentifier";
在viewDidLoad中:
[self.tableView registerNib:[UINib nibWithNibName:@"TotalDistanceTableViewCell" bundle:nil] forCellReuseIdentifier:TotalDistanceCellIdentifier];
然后在 cellForRowAtIndexPath 中:
TotalDistanceTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:TotalDistanceCellIdentifier];
return cell;
在 iOS 5 和 5.1 中,我看到了我的 UITableViewCell。但是在我运行 iOS 6 的 iPhone 或 iOS 6 模拟器上,它崩溃了:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle:.....with name 'TotalDistanceTableViewCell''
iOS 6 中的 UItableViewCells 有什么变化吗?谢谢!
最佳答案
您描述的方式从来都不正确。如果它以前有效,则可能是异常是新的。
只有当您有一个单独的 nib 文件时,您才可以注册一个 nib。对于 Storyboard 中的原型(prototype),只需使用重用标识符出列,tableView 就会根据您的原型(prototype)创建新的单元格。
只需删除 registerNib 行,就可以了。
关于ios - 无法在 iOS 6 中加载 UITableViewCell Nib ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12890114/