Gol*_*App 37 xcode identifier uitableview ios
我的工作是关于`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
Run Code Online (Sandbox Code Playgroud)
我在故事板中检查了我的单元标识符一百次,在我的代码中是相同的.代码(defaut代码UITableViewController):
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell1";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
// Configure the cell...
return cell;
}
Run Code Online (Sandbox Code Playgroud)
表视图单元属性的图片:

我创建并实现了UITableViewCell我的单元格的子类.
知道为什么这不起作用吗?
任何方式(代码行)知道单元格的标识符是什么?
谢谢
编辑:我的界面构建器的屏幕截图.

编辑2:customCell.h的文本
#import <UIKit/UIKit.h>
@interface customCell : UITableViewCell
@end
Run Code Online (Sandbox Code Playgroud)
运行项目时出现新错误:
[<choixActiviteViewController 0x7591ac0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key Cell1.
Run Code Online (Sandbox Code Playgroud)
choixActiviteViewController是UITableViewController的子类,是Choix Activite View Controller的自定义类.
Abd*_*que 79
代替:
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
Run Code Online (Sandbox Code Playgroud)
尝试:
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
Run Code Online (Sandbox Code Playgroud)
如果这不起作用,还添加:
if (cell == nil) {
cell = [[customCell alloc] init];
}
Run Code Online (Sandbox Code Playgroud)
Gol*_*App 14
好的,我的项目终于有效了.关于我删除的东西出现了一些错误,我找不到了.
我刚刚删除了每个TableViewCell,我必须UITableViewCell使用以下属性创建一个新的唯一:
class:customCell
风格:基本(但它也适用于自定义)
标识符:Cell1
感谢您的帮助ssantos,Abdullah Shafique和bilobatum.