【发布时间】:2015-04-01 00:20:40
【问题描述】:
我有一个链接到 UITableVIewCell xib 的自定义 UITableViewCell。当我运行应用程序时,出现错误。
我做了很多搜索,最终找到了this。当我尝试从单元格视图拖动到文件所有者时,该视图似乎不可点击或不可拖动。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"CategorieUITableVIewCell"];
if (cell == nil) {
UIViewController *tempVC = [[UIViewController alloc] initWithNibName:@"CategorieUITableVIewCell" bundle:nil];
cell = (CategorieUITableVIewCell *)tempVC.view;
}
return cell;
}
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "CategorieUITableVIewCell" nib but the view outlet was not set.'
不确定这是否足够清楚,但如果您有任何问题,请提出。
【问题讨论】:
-
检查你是否指定了单元格类的名称CategorieUITableVIewCell
-
我不知道你在哪里搜索过,但这不再是推荐的方法。您应该注册 nib(在 viewDidLoad 中是一个好地方),并摆脱 if cell == nil 子句。
-
goto CategorieUITableVIewCell.xib--> "显示身份检查器"-->自定义类然后检查你的类名
标签: ios objective-c uitableview xib