Could not load NIB in bundle: 'NSBundle'

后端 未结 12 1443
礼貌的吻别
礼貌的吻别 2020-12-03 07:27

What is the error listed below?

2011-02-23 21:24:12.218 Success[7238:207] * Terminating app due to uncaught exception \'NSInternalInconsisten

相关标签:
12条回答
  • 2020-12-03 07:58

    0

    For example If your using a UIViewController class name as TextPicker Then u need to use like Bellow Code

      let bundle = Bundle(for: TextPicker.self)
      super.init(nibName: "TextPicker" , bundle: bundle)
    

    If You are using TableView with Xib in other project as Framework

      tableView.register(UINib.init(nibName: "TextPickerCell", bundle: bundle), forCellReuseIdentifier: "TextPickerCell")
    

    let bundle = Bundle(for: TextPicker.self)

    0 讨论(0)
  • 2020-12-03 08:01

    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];
    
    0 讨论(0)
  • 2020-12-03 08:02

    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.

    0 讨论(0)
  • 2020-12-03 08:03

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

    0 讨论(0)
  • 2020-12-03 08:05

    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.

    0 讨论(0)
  • 2020-12-03 08:07

    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];
    
    0 讨论(0)
提交回复
热议问题