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
'NSInternalInconsistencyException', reason: 'The NIB data is invalid.' for CustomCell
提问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.0
even 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
使用下图中设置的值检查 nib 文件
Check UILabel
UIButton
text also
UILabel
UIButton
也检查文本
回答by Shaheer Palollathil
some time AutoLayout
may 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 Document
uncheck Use Auto Layout
在File Inspector
->Interface Builder Document
取消选中Use Auto Layout
and
和
In File Inspector
->Localization
uncheck Base
and check English
在File Inspector
->Localization
取消选中Base
并选中English