Could not load NIB in bundle: 'NSBundle'

偶尔善良 提交于 2019-11-26 20:53:10

问题


What is the error listed below?

2011-02-23 21:24:12.218 Success[7238:207] * Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/jimkillen12/Library/Application Support/iPhone Simulator/4.2/Applications/BAA5E0E7-AF12-4301-A4F8-1B9797C9E82D/Success.app> (loaded)' with name 'MainWindow-iPad''


回答1:


One of your NIB file is missing from project, add the required NIB file:

In Build Phases

  1. expand Copy Bundle Resources
  2. click + at bottom
  3. add the required NIB file.

Clean your build by Shift+Cmd+K, then run.

P.S. Also make sure to use exact spelling of NIB file while calling initWithNibName:@"ViewNameController"

Probably, you have named your NIB in a call by lowercase letters or you may have also included extension .xib which is not required.




回答2:


Probably, you have named your NIB in a call by lowercase letters. The simulator works fine in this case, but an iPhone device will return an error during runtime.

For example,

DetailViewController *detailViewController = [[DetailViewController alloc]
            initWithNibName:@"detailViewController" bundle:nil];

will fail. You need to change to:

DetailViewController *detailViewController = [[DetailViewController alloc]
            initWithNibName:@"DetailViewController" bundle:nil];



回答3:


In your Build Settings, Add Architecture =>> armv6 and armv7

I just removed my error using this




回答4:


I have got the same problem, but it was because i wrote the extension .xib and it is not neccessary

token_view = [[GetToken alloc] initWithNibName:@"GetToken_iPad.xib" bundle:nil];

instead of

token_view = [[GetToken alloc] initWithNibName:@"GetToken_iPad" bundle:nil];



回答5:


In my case was next:

I loaded in code XIB with name "??????Ipad" but XIB filename was "??????IPad"




回答6:


Are there any warnings related to the NIB? This is usually do to an error in the NIB file (such as incorrect type of NIB).

Right click on the file and click "Get Info" to verify that the type is what you would expect.




回答7:


Please make sure your nib/xib file is included in the corresponding Target Membership.




回答8:


I Have Same Problem Just Follow Steps.

1.Copy your Project In Another Place.

2.Copy your NIB File Which Crash app.

3.Just Change Name

Ex. Old File Demo.xib Than Copy And Change Name DemoNew.xib

My Code is Below

Old Code

Demo *controller = [[Demo alloc]initWithNibName:@"Demo" bundle:nil];

I Just Change Name

Demo *controller = [[Demo alloc]initWithNibName:@"DemoNew" bundle:nil];

its working for me.




回答9:


Just check that file MainWindow.xib exist in your project. If not, just add the new interface file with name MainWindow.xib.




回答10:


An other possible issue: you are using Base Localization on iOS 5 (caution, it kinda work on the iOS Simulator, but not on a device), but it is supported only starting from iOS 6.

For more info, see: Could not load nib in bundle base internationalization




回答11:


If you are trying to load a collectionView cell in a collection view which is picked up from a nib then you might be seeing the error" 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle " When you are loading a collection view from a nib file, you do not have the option to declare a collection view cell on the nib unlike story board. The correct way is to create a new custom cell , with a new nib and then load it on to the collection view. Note : don't forget to register the nib of the new custom collection cell.



来源:https://stackoverflow.com/questions/5099707/could-not-load-nib-in-bundle-nsbundle

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!