NSInternalInconsistencyException,原因:无法在bundle中加载NIB [英] NSInternalInconsistencyException, reason: Could not load NIB in bundle
问题描述
我已经对这个问题进行了大量的回答,但似乎没有与我的问题有关。
I've gone through a bunch of answers regarding this problem but none seem to relate to my problem.
我有两个视图,视图1有一个按钮。 View 2有一个按钮。
I have two views, View 1 has a button. View 2 has a button.
View 1按钮与模型segue绑定到View 2.
View 1 button is tied to a model segue to View 2.
I单击视图1中的按钮,它打开视图2.
I click the Button in View 1, it opens up View 2.
在视图2中,该按钮连接到一个激活的IBAction
In View 2 the button is connected to an IBAction which fires
[self dismissViewControllerAnimated:YES completion:nil];
关闭视图并再次显示视图1 - 现在如果我再次按下视图1上的按钮我获取
Which closes the View and displays View 1 again - Now if I press the Button on View 1 again I get
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle <x/y/z/SomeApp.app> (loaded)' with name 'tvz-Io-ndz-view-rB8-bq-l6j' and directory 'Main.storyboardc''
我完全失去了如何解决这个问题。请帮忙!
I'm completely lost how to fix this problem. Please help!
编辑:
- 只有在设备没有时才会发生有互联网
- 如果我的链中有第三个屏幕,其中有一个webview呈现图像,如果我从View 2转到该屏幕,则应用程序不会崩溃。
编辑2:
我也尝试过从头开始重建屏幕。
I've also tried rebuilding the screen from scratch.
我完全感到困惑。
编辑3:完整Stacktrace
EDIT 3: Full Stacktrace
2015-01-19 09:10:58.528 SomeApp[37747:2203364] *** Terminating app due to
uncaught exception 'NSInternalInconsistencyException', reason: 'Could not
load NIB in bundle: 'NSBundle
</Users/user/Library/Developer/CoreSimulator/Devices/D23C1B7C-7330-
466E-8369-762C6727B19C/data/Containers/Bundle/Application/AE67C3D3-C5AE-
4A66-91EC-54D976A4A4FC/SomeApp.app> (loaded)' with name 'tvz-Io-ndz-view-
rB8-bq-l6j' and directory 'Main.storyboardc''
*** First throw call stack:
(
0 CoreFoundation 0x01f64946 __exceptionPreprocess + 182
1 libobjc.A.dylib 0x01beda97 objc_exception_throw + 44
2 CoreFoundation 0x01f6486d +[NSException raise:format:] + 141
3 UIKit 0x008f8e06 -[UINib instantiateWithOwner:options:] + 1003
4 UIKit 0x0071b624 -[UIViewController _loadViewFromNibNamed:bundle:] + 270
5 UIKit 0x0071bdbb -[UIViewController loadView] + 295
6 UIKit 0x0071bfef -[UIViewController loadViewIfRequired] + 78
7 UIKit 0x0071c595 -[UIViewController view] + 35
8 UIKit 0x00d8f707 -[_UIFullscreenPresentationController _setPresentedViewController:] + 75
9 UIKit 0x006f1a81 -[UIPresentationController initWithPresentedViewController:presentingViewController:] + 113
10 UIKit 0x00729a61 -[UIViewController _presentViewController:withAnimationController:completion:] + 2102
11 UIKit 0x0072c5d2 __62-[UIViewController presentViewController:animated:completion:]_block_invoke + 345
12 UIKit 0x0072c424 -[UIViewController presentViewController:animated:completion:] + 224
13 UIKit 0x0072c8ea -[UIViewController presentModalViewController:animated:] + 57
14 UIKit 0x00bf448d -[UIStoryboardModalSegue perform] + 271
15 UIKit 0x00be1b49 -[UIStoryboardSegueTemplate _perform:] + 217
16 UIKit 0x00be1bc5 -[UIStoryboardSegueTemplate perform:] + 116
17 UIKit 0x006d4907 -[UITableView _selectRowAtIndexPath:animated:scrollPosition:notifyDelegate:] + 1490
18 UIKit 0x006d4af7 -[UITableView _userSelectRowAtPendingSelectionIndexPath:] + 285
19 UIKit 0x006d9df3 __38-[UITableView touchesEnded:withEvent:]_block_invoke + 43
20 UIKit 0x005ee0ce ___afterCACommitHandler_block_invoke + 15
21 UIKit 0x005ee079 _applyBlockToCFArrayCopiedToStack + 415
22 UIKit 0x005ede8e _afterCACommitHandler + 545
23 CoreFoundation 0x01e879de __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 30
24 CoreFoundation 0x01e87920 __CFRunLoopDoObservers + 400
25 CoreFoundation 0x01e7d35a __CFRunLoopRun + 1226
26 CoreFoundation 0x01e7cbcb CFRunLoopRunSpecific + 443
27 CoreFoundation 0x01e7c9fb CFRunLoopRunInMode + 123
28 GraphicsServices 0x043d524f GSEventRunModal + 192
29 GraphicsServices 0x043d508c GSEventRun + 104
30 UIKit 0x005c48b6 UIApplicationMain + 1526
31 SomeApp 0x000e482d main + 141
32 libdyld.dylib 0x027e8ac9 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
James
推荐答案
可能有很多原因会导致您收到错误。
There can be quite a number of reasons that could raise the error you're receiving.
我将开始列举一些要检查的内容和解决方案:
I'll start enumerating some things to check for and solutions:
-
你有没有重命名你的xi b或Xcode外的故事板文件?如果是这样,请检查您所引用的任何地方是否存在不一致。另外,请确保在引用文件的任何地方都尊重大写/小写字母,因为区分大小写。
Have you renamed your xib or storyboard file outside Xcode? If so, check everywhere you have a reference to it for inconsistencies. Also be sure you respect the uppercase / lowercase letters anywhere you reference the file since is case sensitive.
转到Interface Builder,选择View1 ViewController> Utilities Panel > Identity Inspector
>>检查自定义类
是否对应于ViewController类(如果有)(.h和.m)文件)。
Go to Interface Builder, select your View1 ViewController > Utilities Panel > Identity Inspector
> check if the Custom Class
corresponds to your ViewController Class if you have one (.h and .m files).
检查 Info.plist
文件。如果您使用storyboads,则应该有一个类似主故事板文件基本名称
和NOT 主nib文件基本名称
的条目。如果使用笔尖,则反之亦然。还要检查文件基名是否与实际文件的名称一致。
Check your Info.plist
file. If you use storyboads, you should have an entry like Main storyboard file base name
and NOT Main nib file base name
. If you use nibs, then is vice-versa. Also check that the file base name corresponds with name of the actual file.
检查目标的构建阶段>复制捆绑资源
并确保在那里添加了xib或storyboard文件。
Check your target's Build Phases > Copy Bundle Resources
and make sure that your xib or storyboard file is added there.
如果以编程方式实例化View1 ViewController并使用xib文件检查错别字的笔尖名称(请记住,区分大小写)。
此外,如果您当前将.xib文件格式附加到名称,请删除该扩展名,因为它不应使用。我的意思是这行代码: UIViewController * controller = [[UIViewController alloc] initWithNibName:@xibFileNamebundle:nil];
If you instantiate your View1 ViewController programmatically and you use xib file check the nib name for typos (remember, is case-sensitive).
Also, if you currently append .xib file format to the name, remove the extension because it shouldn't be used. What I mean is this line of code: UIViewController *controller = [[UIViewController alloc] initWithNibName:@"xibFileName" bundle:nil];
在文件检查器中检查xib或storyboard文件的属性,并确保您的文件在目标成员
选择面板。
Check the properties of your xib or storyboard file in the file inspector and make sure that your file is linked to your target in the Target Membership
selection panel.
检查文件检查器中xib或storyboard文件的属性,然后尝试切换文件 Location
到相对于项目
或相对于组
。看看两种方式是否有所不同。
Check the properties of the xib or storyboard file in the file inspector and try switching your file Location
to Relative to project
or Relative to group
. See if either way makes a difference.
如果您在 initWithCoder
然后你应该在 viewDidLoad
方法中实例化它
If you're adding your view controller programmatically in the initWithCoder
then you should instantiate it in the viewDidLoad
method instead
如果上述情况不适用于你的情况,您可以从Xcode中删除该文件(选择删除参考
)并在项目中再次导入。
If nothing from above applies to your situation, you could delete the file from Xcode (select Remove References
) and import it again in your project.
请记住,在进行上述更改后,请务必清理您的项目(SHIFT + COMMAND + K)。
Remember to ALWAYS clean your project after making the above changes (SHIFT+COMMAND+K).
如果有,请告诉我们它有效,有效。
Please let us know if it worked and what worked.
这篇关于NSInternalInconsistencyException,原因:无法在bundle中加载NIB的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!