xcode 无法加载捆绑包中的 NIB
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6827949/
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
Could not load NIB in bundle
提问by Tim
*Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle (loaded)' with name 'ViewLecturer'
*由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“无法加载包中的 NIB:“NSBundle(已加载)”,名称为“ViewLecturer”
ViewLecturer *viewLecturer = [[ViewLecturer alloc]initWithNibName:@"ViewLecturer" bundle:nil];
[self.navigationController pushViewController:viewLecturer animated:YES];
I've check the file type and it's file.xib.
Doubled check the xib name is ViewLecturer but i still constantly get the error on the device.
Works fine on the stimulator though.
我检查了文件类型,它是file.xib。
再次检查 xib 名称是 ViewLecturer,但我仍然不断在设备上收到错误消息。不过在刺激器上效果很好。
回答by
ViewLecturer *viewLecturer = [[ViewLecturer alloc]
initWithNibName:@"ViewLecturer" bundle:nil];
You have to take care of two things :
你必须注意两件事:
- this call assumes you have a file named 'ViewLecturer.xib' and not 'file.xib'
- make sure the file is included in the app bundle. Check that in the build phases > copy ressources to bundle.
- 此调用假定您有一个名为“ViewLecturer.xib”而不是“file.xib”的文件
- 确保该文件包含在应用程序包中。检查在构建阶段> 将资源复制到捆绑包中。
回答by visakh7
Make sure you use the correct file names, iOS is case sensitive, simulator is not. so if it works in simulator but not on device check the cases on the file name...
确保使用正确的文件名,iOS 区分大小写,模拟器不区分大小写。因此,如果它在模拟器中有效但在设备上无效,请检查文件名中的大小写...
回答by Liam
Just found another reason for this. Normally when you add a new file to the project xcode will automatically add it to the "Copy Bundle resources" section of your target.
刚刚找到了另一个原因。通常,当您将新文件添加到项目时,xcode 会自动将其添加到目标的“复制捆绑资源”部分。
Sometimes, if you are collaborating with another person the project.pbxproj will get out of sync and this entry will get removed. The fix is to ensure that all the files in the Resources folder (that are required in the release) are also present in the "Copy Bundle resources" section, and if it isn't just drag it from the resources to that section.
有时,如果您与其他人合作,project.pbxproj 将不同步,此条目将被删除。修复方法是确保 Resources 文件夹中的所有文件(发行版中需要的)也存在于“复制捆绑资源”部分中,如果它不只是将其从资源拖到该部分。
Enjoy!
享受!
回答by Tendulkar
This issue is regarding the nibname .Check the nib name .
此问题与笔尖名称有关。检查笔尖名称。