Xcode 4.2“笔尖(Cell)中的单元重用标识符与用于注册笔尖(ThisCell)的标识符不匹配”

问题描述 投票:6回答:2

我正在尝试使用Xcode 4.2的新StoryBoard功能,并在将表视图与自定义单元格一起使用时不断出现此错误。

cell reuse indentifier in nib (Cell) does not match the identifier used to register the nib (ThisCell)

我已将自定义单元格的类设置为我的自定义UITableViewCell类,并在IB中将标识符设置为“ ThisCell”。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {     
static NSString *CellIdentifier = @"ThisCell";
//TableViewCell *cell = (TableViewCell*)[tableView dequeueReusableCellWithIdentifier:@"ThisCell"];
TableViewCell *cell = (TableViewCell *) [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
return cell;

我不知道“细胞”的来源。有任何想法吗?我试图在另一个项目中加载自定义单元,但看起来工作正常,我只是找不到有关此错误的任何文档来找出我在当前项目中所犯的错误。

谢谢

iphone ios xcode uitableview xcode4.2
2个回答
13
投票

错误消息指出,在您的笔尖中,该单元格被标识为“单元格”-您需要查看xib文件,该文件定义了用于配置单元格重用标识符的自定义单元格,并将其设置为ThisCell ...或仅在此代码中将ThisCell更改为Cell。


0
投票

请看一下项目中的以下两个地方。并确保它们两个字符串标识符相同。

Check in Storyboard/Xib hereIn code check this line in cellforRowAtIndexPath method

© www.soinside.com 2019 - 2024. All rights reserved.