NSInternalInconsistencyException, reason: Could not load NIB in bundle

后端 未结 8 2072
轻奢々
轻奢々 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: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];
    

提交回复
热议问题