Xcode 4.2“nib (Cell) 中的单元重用标识符与用于注册 nib (ThisCell) 的标识符不匹配”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7797052/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode 4.2 "cell reuse indentifier in nib (Cell) does not match the identifier used to register the nib (ThisCell)"
提问by Tyler DeWitt
I'm trying to use the new StoryBoard feature of Xcode 4.2 and keep getting this error when using a Table View with a custom cell.
我正在尝试使用 Xcode 4.2 的新 StoryBoard 功能,并在使用带有自定义单元格的表格视图时不断收到此错误。
cell reuse indentifier in nib (Cell) does not match the identifier used to register the nib (ThisCell)
cell reuse indentifier in nib (Cell) does not match the identifier used to register the nib (ThisCell)
I've set the class of my custom cell to my custom UITableViewCell class and set the Identifier to "ThisCell" in IB.
我已将自定义单元格的类设置为自定义 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;
I have no idea where "Cell" is coming from. Any ideas? I tried loading a custom cell in another project, and it seems to work fine, I just can't find any documentation on this error to find out what I messed up in the current project.
我不知道“细胞”是从哪里来的。有任何想法吗?我尝试在另一个项目中加载自定义单元格,它似乎工作正常,我只是找不到有关此错误的任何文档来找出我在当前项目中搞砸的内容。
Thanks
谢谢
回答by Duncan Babbage
The error message states that in your nib the cell is identified as "Cell"—you need to look in the xib file that defines your custom cells for configuration of the Cell Reuse Identifier, and set that to ThisCell... Or just change ThisCell to Cell in this code.
错误消息指出,在您的笔尖中,单元格被标识为“单元格”——您需要查看定义您的自定义单元格的 xib 文件以配置单元格重用标识符,并将其设置为 ThisCell... 或者只是更改 ThisCell到此代码中的单元格。