【发布时间】:2013-10-05 17:30:05
【问题描述】:
我的工作是关于 `UITableView.每次我运行我的项目时,都会出现这个错误:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier Cell1 - must register a nib or a class for the identifier or connect a prototype cell in a storyboard
我检查了一百次我的故事板中的单元格标识符和我的代码中的相同。
代码(来自UITableViewController的默认代码):
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell1";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// Configure the cell...
return cell;
}
表格视图单元格属性的图片:
我为我的单元创建并实现了UITableViewCell 的子类。
知道为什么这不起作用吗?
任何方式(代码行)知道单元格的标识符是什么?
谢谢
编辑:我的界面构建器的屏幕截图。
编辑 2:customCell.h 的文本
#import <UIKit/UIKit.h>
@interface customCell : UITableViewCell
@end
运行项目时出现新错误:
[<choixActiviteViewController 0x7591ac0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key Cell1.
choixActiviteViewController 是 UITableViewController 的子类,是 Choix Activite View Controller 的自定义类。
【问题讨论】:
-
请附上一些相关代码。属性检查器的屏幕截图也会很有用。
-
你是如何实例化你的视图控制器的?如果它没有通过 segue 或
[UIStoryboard instantiateViewControllerWithIdentifier:]从情节提要中实例化,则您的情节提要原型将不会被注册。 -
这个
UITableViewController是我的第一个视图。之前只有一个导航控制器,关系为“rootviewcontroller”。 -
您是否检查过 tableView 是否正确链接到控制器?
-
@TimothyMoose.. 你先生,今晚是英雄.. 我心不在焉地通过 alloc/init 启动了我的测试 tableViewController 并花了一个小时试图弄清楚为什么我的原型被忽略了.. 谢谢..
标签: ios xcode uitableview identifier