3

我收到类似的错误
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'The NIB data is invalid.'

iOS 5.0即使我取消选中 AutoLayout 并为 customcell 的所有版本的 iOS 提供部署支持。

 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {

        static NSString *CustomCellIdentifier = @"GroupListCell";

        GroupListCell *cell = (GroupListCell *)[tableView dequeueReusableCellWithIdentifier: CustomCellIdentifier];

            if (cell == nil)
            {
                NSArray *nib;

                if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad)
                {
                    nib= [[NSBundle mainBundle] loadNibNamed:@"GroupListCell" owner:self options:nil];
                }
                else{
                    nib= [[NSBundle mainBundle] loadNibNamed:@"GroupListiPhoneCell" owner:self options:nil]; // sigabrt
                }
                // cell implementation code..
           }
}

此代码适用于 iOS6.0,但不适用于 iOS 5.0。
问题是什么?我错过了什么吗?

4

5 回答 5

15

使用下图中设置的值检查 nib 文件
在此处输入图像描述

还要检查UILabel UIButton文本

在此处输入图像描述

于 2013-02-22T07:48:38.363 回答
4

一段时间AutoLayout也可能会导致问题。所以采取 xib 文件-检查器窗格-取消勾选autolayout

于 2013-08-15T09:47:34.747 回答
2

最后我发现了问题。

我的单元格中有一个 textview,即使 Text 属性定义为“Plain”,它也具有属性文本。它在“普通”中没有改变。因为手动更改文本并使用 enter 关键字转到下一行。在内部,它被认为是“属性”。

所以检查 TextView 的文本属性 2 次。:)

于 2013-02-22T11:04:22.763 回答
1

在您的情况下,可能缺少用于提取单元格的代码。希望以下更正的代码有效。

if (cell == nil)
            {
                NSArray *nib;

                if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPad)
                {
                    nib= [[NSBundle mainBundle] loadNibNamed:@"GroupListCell" owner:self options:nil];

                  cell = [nib objectAtindex:0]; 
                }
                else{
                    nib= [[NSBundle mainBundle] loadNibNamed:@"GroupListiPhoneCell" owner:self options:nil]; // sigabrt
                  cell = [nib objectAtindex:0];
                }
                // cell implementation code..
           }
于 2013-02-22T07:07:50.830 回答
1

对于较低版本的 iOS 6,它可能会发生。

为了解决这个问题

然后选择故事板

File Inspector->Interface Builder Document取消选中Use Auto Layout

File Inspector->Localization取消选中Base并选中English

于 2014-10-26T06:36:32.143 回答