NSInternalInconsistencyException, reason: Could not load NIB in bundle

后端 未结 8 1982
轻奢々
轻奢々 2020-12-03 08:55

I\'ve gone through a bunch of answers regarding this problem but none seem to relate to my problem.

I have two views, View 1 has a button. View 2 has a button.

相关标签:
8条回答
  • 2020-12-03 09:02

    I faced this when I extracted a .app from a zip file and attempted to run it, both on an iOS device and on Simulator.

    One .nib file had been named with non-latin characters (fileNormal.nib with the greek letters No) and when extracted from the zip, it was assigned letters from another charset (it should be Greek-DOS or something compatible). I chose a different charset upon extraction and it worked as it should.

    Just putting this in case someone else faces the same problem ;)

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

    I tried all above answer but they didn't work. For me, the solution was to include the xib to the target resource.

    Steps performed:

    • Click on xib file.
    • Open Identity Inspector -> Target Membership and check second option (ProjectName_Resource)
    0 讨论(0)
  • 2020-12-03 09:08

    You may have to setup the bundle for the class before accessing the xib:

    ObjectiveC:

    //Bundle initialisation
    NSBundle* bundle = [NSBundle bundleForClass:[self class]];
    
    //Initialising the nib
    UIView *nibView = [[bundle loadNibNamed:@"nibFileName" owner:self options:nil] objectAtIndex:0];
    
    //Display the ad (this will vary based on your application setup)
    [[[UIApplication sharedApplication] keyWindow] addSubview:nibView];
    
    0 讨论(0)
  • 2020-12-03 09:08

    In my case exact same exception was caused by the fact that two controllers had same storyboard id (within one storyboard)

    0 讨论(0)
  • 2020-12-03 09:14

    It's also possible the UITableViewDataSource or UITableViewDelegate are not implemented in the desired UIViewController

    0 讨论(0)
  • 2020-12-03 09:17

    If you're working with cocoapods, it may also help to run pod update. One of my teammates changed a pod around which resulted in that error, so pod update fixed it for me.

    0 讨论(0)
提交回复
热议问题