ios - 无法在 bundle 中加载 NIB! TableView 中的海关单元格

标签 ios objective-c uitableview

我的 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/

相关文章:

ios - 我可以仅从 csproj 构建 Xamarin iOS 而不使用解决方案命令行吗

ios - 以编程方式定义的不同行为 NSLayoutConstraints 与 'greaterThanOrEqual' 的 Storyboard 约束

ios - iOS App亚洲语言本地化

ios - 从 GCD 推送 View Controller 时的长时间延迟

ios - 如何在 iOS Objective-c 的 UICollectionView 中创建无限滚动

objective-c - NSEntityDescription 未找到

ios - 尝试设置 UILabel 的文本时 UIImage 消失

ios - 如何给 UITableViewController 添加 Accordion 效果?

ios - 基于indexPath.row的自定义表格单元格操作不起作用?

objective-c - 如何自定义 NSOutlineView 以具有边框颜色?