xcode 'NSInternalInconsistencyException',原因:'NIB 数据无效。用于自定义单元

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/15018578/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 02:50:14  来源:igfitidea点击:

'NSInternalInconsistencyException', reason: 'The NIB data is invalid.' for CustomCell

iphoneiosxcodeios5ios6

提问by KDeogharkar

I am getting error like
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'The NIB data is invalid.'

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

For iOS 5.0even if I uncheck the AutoLayout and make deployment support for All version of iOS for the customcell .

对于iOS 5.0即使我取消了自动版式,并为所有版本的iOS为customcell部署支持。

 - (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..
           }
}

This code is working fine with iOS6.0 but not for iOS 5.0.
what is the issue? am I missing something.

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

采纳答案by KDeogharkar

Finally I found the issue.

最后我发现了这个问题。

I have one textview in my cell and it has attributed text even if the Text property is define as "Plain". It is not changed in "Plain". Because changes are made in text Manually and use enter keyword to go to next line. Internally it is considered as "Attributed".

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

So check the text property for the TextView 2 times. :)

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

回答by Anil Varghese

Check nib file with values set in the below figure
enter image description here

使用下图中设置的值检查 nib 文件
在此处输入图片说明

Check UILabelUIButtontext also

UILabelUIButton也检查文本

enter image description here

在此处输入图片说明

回答by Shaheer Palollathil

some time AutoLayoutmay also cause problem. So take xib file - inspector pane - un tick autolayout.

一些时间AutoLayout也可能导致问题。所以拿 xib 文件 - 检查面板 - 取消勾选autolayout

回答by AppleDelegate

The code for extracting the cell might be missing in your case.Hope the below corrected code works.

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

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..
           }

回答by MaxEcho

For lower version of iOS 6 it can happen.

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

To solve this problem

为了解决这个问题

Select storyboard then

然后选择故事板

In File Inspector->Interface Builder Documentuncheck Use Auto Layout

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

and

In File Inspector->Localizationuncheck Baseand check English

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