Xcode无法使用标识符将单元格出列 [英] Xcode unable to dequeue a cell with identifier

查看:192
本文介绍了Xcode无法使用标识符将单元格出列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的工作是关于`UITableView。每次运行我的项目时,都会出现此错误:

my work is about `UITableView. Each time I run my project, this error appears :

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 的defaut代码):

I checked a hundred times my cell identifier in my storyboard and in my code are the same. Code (defaut code from UITableViewController) :

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
    static NSString *CellIdentifier = @"Cell1";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    // Configure the cell...

    return cell;
}

表格查看单元格属性的图片:

Picture of Table View Cell properties :

我创建并实现了<$ c的子类$ c> UITableViewCell 我的手机。

I created and implemented a subclass of UITableViewCell for my cell.

知道为什么这不起作用吗?

Any idea why this is not working ?

任何方式(代码行)知道单元格的标识符是什么?

Any way (line of code) to know what is the identifier of a cell ?

谢谢

编辑:我的界面构建器的屏幕截图。

Edit : Screenshot of my interface builder.

编辑2:customCell.h文本

Edit 2 : Text of customCell.h

#import <UIKit/UIKit.h>

@interface customCell : UITableViewCell

@end

运行项目时出现新错误:

New error appears when I run the project :

[<choixActiviteViewController 0x7591ac0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key Cell1.

choixActiviteViewController是UITableViewController的子类,是Choix Activite View Controller的自定义类。

choixActiviteViewController is a subclass of UITableViewController and is the custom class of Choix Activite View Controller.

推荐答案

而不是:

 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

尝试:

 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

如果这不起作用,还可以添加:

if this does not work then, also add:

  if (cell == nil) {
    cell = [[customCell alloc] init];
}

这篇关于Xcode无法使用标识符将单元格出列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆