NSInternalInconsistencyException',原因:'无法加载NIB在bundle:'NSBundle [英] NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle

查看:520
本文介绍了NSInternalInconsistencyException',原因:'无法加载NIB在bundle:'NSBundle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的AppDelegate有一个我不明白的问题。 RootViewController最初调用ViewController,我改变了它的名字。该应用程序由许多ViewController形成,然后我已经介绍了一个UINavigationController。为什么会出现此错误?

  NSInternalInconsistencyException',原因:'无法加载NIB in bundle:'NSBundle 
/ / XXXXXXXXXXXX / Library / Application Support / iPhone simulator / 6.0 / Applications /
B7A7D461-1CFE-4B05-AF32-00B65FCFFF49 / XXXXXXXXXX.app> (加载)'名称
'RootViewController''

***第一次调用堆栈:
(0x1992012 0x1357e7e 0x1991deb 0x4bafac 0x37fe37 0x380418 0x380648 0x380882 0
x380b2a 0x397ef5 0x397fdb x398286 0x398381 0x398eab 0x398fc9 0x399055 0x49e3ab
0x2ef92d 0x136b6b0 0x1f12fc0 0x1f0733c 0x1f12eaf 0x38e8cd 0x2d71a6 0x2d5cbf
0x2d5bd9 0x2d4e34 0x2d4c6e 0x2d5a29 0x2d8922 0x382fec 0x2cfbc4 0x2cfdbf
0x2cff55 0x2d8f67 0x2b30 0x29c7b7 0x29cda7 0x29dfab 0x2af315 0x2b024b 0x2a1cf8
0x1dbedf9 0x1dbead0 0x1907bf5 0x1907962 0x1938bb6 0x1937f44 0x1937e1b 0x29d7da
0x29f65c 0x269d 0x25c5)
ibc ++ abi.dylib:terminate调用抛出异常
(lldb)
pre>

这是AppDelegate.h中的代码

  #import < UIKit / UIKit.h> 

@class RootViewController;

@interface AppDelegate:UIResponder< UIApplicationDelegate> {

UINavigationController * navigationController;
}

@property(强,非原子)UIWindow * window;

@property(strong,nonatomic)RootViewController * viewController;
@property(strong,nonatomic)UINavigationController * navigationController;



@end

AppDelegate.m的代码

  #importAppDelegate.h

#importRootViewController.h



@implementation AppDelegate

@synthesize navigationController;
@synthesize viewController;
@synthesize window;



- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
//在应用程序启动后覆盖自定义点。

if([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone){
self.viewController = [[RootViewController alloc] initWithNibName:@RootViewController_iPhone.xibbundle:nil];
} else {
self.viewController = [[RootViewController alloc] initWithNibName:@RootViewController_iPad.xibbundle:nil];
}

RootViewController * rootMenu = [[RootViewController alloc] initWithNibName:@RootViewControllerbundle:nil];

self.navigationController = [[UINavigationController alloc] initWithRootViewController:rootMenu];

self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;提前感谢

h2_lin>解决方案

当您重命名XCode之外的文件时,可能会发生此错误。
要解决它,您只需从项目中删除文件(右键单击 - 删除和删除参考)。



然后可以重新导入您的项目中的文件和一切都会正常。


In my AppDelegate there is a problem I do not understand. RootViewController initially called ViewController and I changed it name. The application is formed by many ViewController then I have introduced a UINavigationController. Why this error comes?

  NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle 
  /Users/XXXXXXXXXXXX/Library/Application Support/iPhone simulator/6.0/Applications/
  B7A7D461-1CFE-4B05-AF32-00B65FCFFF49/XXXXXXXXXX.app> (loaded)'with name 
 'RootViewController''

  *** First throw call stack:
  (0x1992012 0x1357e7e 0x1991deb 0x4bafac 0x37fe37 0x380418 0x380648 0x380882 0
  x380b2a  0x397ef5 0x397fdb x398286 0x398381 0x398eab 0x398fc9 0x399055 0x49e3ab 
  0x2ef92d 0x136b6b0 0x1f12fc0 0x1f0733c 0x1f12eaf 0x38e8cd 0x2d71a6 0x2d5cbf 
  0x2d5bd9 0x2d4e34 0x2d4c6e 0x2d5a29 0x2d8922 0x382fec 0x2cfbc4 0x2cfdbf 
  0x2cff55 0x2d8f67 0x2b30 0x29c7b7 0x29cda7 0x29dfab 0x2af315 0x2b024b 0x2a1cf8 
  0x1dbedf9 0x1dbead0 0x1907bf5 0x1907962 0x1938bb6 0x1937f44 0x1937e1b 0x29d7da
  0x29f65c 0x269d 0x25c5) 
  ibc++abi.dylib: terminate called throwing an exception
  (lldb) 

This is the code in AppDelegate.h

  #import <UIKit/UIKit.h>

  @class RootViewController;

  @interface AppDelegate : UIResponder <UIApplicationDelegate>{

       UINavigationController *navigationController;
   }

  @property (strong, nonatomic) UIWindow *window;

  @property (strong, nonatomic) RootViewController *viewController;
  @property (strong, nonatomic) UINavigationController * navigationController;



  @end

This is the code of AppDelegate.m

  #import "AppDelegate.h"

  #import "RootViewController.h"



  @implementation AppDelegate

  @synthesize navigationController;
  @synthesize viewController;
  @synthesize window;



  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:    (NSDictionary *)launchOptions
 {
         self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        // Override point for customization after application launch.

         if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
               self.viewController = [[RootViewController alloc]      initWithNibName:@"RootViewController_iPhone.xib" bundle:nil];
   } else {
    self.viewController = [[RootViewController alloc] initWithNibName:@"RootViewController_iPad.xib" bundle:nil];
   }

    RootViewController *rootMenu=[[RootViewController alloc]initWithNibName:@"RootViewController" bundle:nil];

    self.navigationController =[[UINavigationController alloc]initWithRootViewController:rootMenu];

    self.window.rootViewController = self.navigationController;
    [self.window makeKeyAndVisible];
    return YES;
}

Thanks in advance

解决方案

This error can occur when you rename files outside of XCode. To solve it you can just remove the files from your project (Right Click - Delete and "Remove Reference").

Then after you can re-import the files in your project and everything will be OK.

这篇关于NSInternalInconsistencyException',原因:'无法加载NIB在bundle:'NSBundle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆