2013-02-28 23 views
0

我有问题之间切换视图控制器。NSInternalInconsistencyException错误

我md360AppDelegate.h头看起来像这样

#import <UIKit/UIKit.h> 
@class md360ViewController; 
@interface md360AppDelegate : UIResponder <UIApplicationDelegate> 
@property (strong, nonatomic) UIWindow *window; 
@property (strong, nonatomic) md360ViewController *viewController; 
@property (strong, nonatomic) UINavigationController *navigationController; 
@end 

和我md360AppDelegate.m实施看起来是这样的。

#import "md360AppDelegate.h" 
#import "md360ViewController.h" 

@implementation md360AppDelegate 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{ 
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 
    // Override point for customization after application launch. 
    self.viewController = [[md360ViewController alloc] initWithNibName:@"md360ViewController" bundle:nil]; 
    self.navigationController = [[UINavigationController alloc] initWithRootViewController:self.viewController]; 
    [self.navigationController setNavigationBarHidden:YES animated:YES]; 
    [self.window setRootViewController:self.navigationController]; 
    [self.window makeKeyAndVisible]; 
    return YES; 
} 
@end 

我正在创建一个UINavigationController实例并将其存储在此类的navigationController属性中。

我想在用户点击md360ViewController中的按钮时更改ViewController。

我的md360ViewController.h看起来像这样。

@interface md360ViewController : UIViewController 
@property IBOutlet UIButton *homePathwayBtn; 
@property IBOutlet UIButton *homeDiseaseBtn; 
@property IBOutlet UIButton *homePipelineBtn; 
- (IBAction)homeButton:(id)sender; 
@end 

和我的实现看起来像

#import "md360ViewController.h" 
#import "md360AppDelegate.h" 
#import "pipeViewDisease.h" 
#import <QuartzCore/QuartzCore.h> 

    - (IBAction)homeButton:(id)sender { 
     UIViewController *pipeViewDisease = [[UIViewController alloc] initWithNibName:@"pipeViewDiease" bundle:nil]; 
     [self.navigationController pushViewController:pipeViewDisease animated:YES]; 
    } 

,当我在UIButton的点击应用程序崩溃与下面的消息。

终止应用程序由于未捕获的异常 'NSInternalInconsistencyException',理由是: '在 包无法加载NIB: '一个NSBundle (加载)' 名为'pipeViewDiease'

可能是什么问题?

回答

1

可能只是一个拼写错误的NIB名称:

initWithNibName:@"pipeViewDiease" 

应该是:

initWithNibName:@"pipeViewDisease" 
          ^
+0

哈哈,最好的错字,谢谢:) – 2013-02-28 13:24:09

+0

@IbrahimAzharArmar它发生了。 – trojanfoe 2013-02-28 13:24:39

1

除非它是一个拼写错误(应该是pipeViewDisease),这个错误当文件被重新通常发生在xCode环境之外命名。

要解决这个问题:

  • 从项目
  • 重新导入文件中删除有问题的文件到您的项目。
相关问题