我的 tableView
有问题。我想在 tableView
中有 6 个不同的单元格。
所以,在 viewDidLoad
中,我有这个:
[_tableView registerNib:[UINib nibWithNibName:@"KBCategoriePriceTableViewCell" bundle:nil]
forCellReuseIdentifier:@"KBCategoriePriceTableViewCell"];
对于其他单元格,它是相同的代码,并且在 cellForRowAtIndexPath
中:
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
NSString* nameCell = [array objectAtIndex:indexPath.row];
if([nameCell isEqualToString:CELL_VIEW_CATEGORY_PRICE]){
KBCategoriePriceTableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"KBCategoriePriceTableViewCell"];
[cell setBackgroundColor:[[receive category] colorBackground]];
[cell.buttonCategorie setTitle:@"" forState:UIControlStateNormal];
[cell.buttonCategorie setEnabled:NO];
[cell.buttonCategorie setImage:[UIImage imageNamed:[[receive category] imageName]]forState:UIControlStateNormal];
[cell.buttonDevise setTitle:[[receive devise] symbole] forState:UIControlStateNormal];
[cell.buttonCategorie setEnabled:NO];
[cell setSelectionStyle:UITableViewCellSelectionStyleNone];
return cell;
}
}
但是当我启动我的应用程序时,它崩溃了!出现此错误消息:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/jean-nicolasdefosse/Library/Application Support/iPhone Simulator/7.1/Applications/20031DF6-D297-44D0-9D67-4AD3439D85F7/KillTheBill.app> (loaded)' with name 'KBCategoriePriceTableViewCell''
我不明白为什么它不起作用。
我删除引用并在项目中添加文件,我检查目标和自定义单元格 KBCategoriePriceTableViewCell
在“xib”中具有标识符:KBCategoriePriceTableViewCell
。
请帮帮我!
最佳答案
错误消息说您的项目中没有名为 KBCategoriePriceTableViewCell.nib
的文件。
此外,您应该始终在 tableView:cellForRowAtIndexPath:
中返回一个单元格。
关于ios - 无法在 bundle 中加载 NIB! TableView 中的海关单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23865252/