2013-08-16 148 views
0

在我的应用程序中,我自定义标签栏有5个选项卡,每个选项卡显示不同的UIViewController笔尖加载失败

应用程序仅适用于iPhone,所以我为每个UIViewController制作了2个NIB(如果类名是DayView,NIB是DayView_iPhone和DayView_iPhone5)。在设备以及模拟器中,一切都可以正常工作长达10分钟。

之后,应用程序崩溃显示此控制台:

Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle </Users/kalyanasadinagarajugari/Library/Application Support/iPhone Simulator/6.1/Applications/0DEBB118-BA67-440F-BA70-79ED41AC9134/CalendarBlender.app> (loaded)' with name 'DayView_iPhone'' 

我查了NIB名也,每NIB文件名是正确的。

而且我的代码是

NSString *nibName = [AppDelegate fetchNibWithViewControllerName:@"DayView"]; 
dayView = [[DayView alloc] initWithNibName:nibName bundle:nil]; 

if (IS_IPHONE_5) 
    dayView.view.frame = CGRectMake(0, 44, 320, 463); 
else 
    dayView.view.frame = CGRectMake(0, 44, 320, 375); dayView.view.tag=2; [self.view  
addSubview:dayView.view]; 
+0

选中此: - http://stackoverflow.com/questions/5099707/could-not-load-nib-in-bundle-nsbundle –

回答

0

尝试检查Nibname(区分大小写),清理项目,重新运行它。你是否改变了所有笔尖的班名?

+1

每个Nibname是完美的,我检查了所有nibnames。在连续更改标签后,我的问题就会发生。 – Joker

+0

你可以粘贴代码吗? – SRI

+0

NSString * nibName = [AppDelegate fetchNibWithViewControllerName:@“DayView”]; dayView = [[DayView alloc] initWithNibName:nibName bundle:nil];如果(IS_IPHONE_5) dayView.view.frame = CGRectMake(0,44,320,463);如果(IS_IPHONE_5) else dayView.view.frame = CGRectMake(0,44,320,375); dayView.view.tag = 2; [self.view addSubview:dayView.view]; – Joker

0

使用此:

- (void)applicationDidFinishLaunching:(UIApplication *)application { 
    tabBarController = [[UITabBarController alloc] init]; 

    MyViewController* vc1 = [[MyViewController alloc] initWithNibName:@"nibName" bundle:nil]; 
    MyOtherViewController* vc2 = [[MyOtherViewController alloc] initWithNibName:@"nibName" bundle:nil]; 

    NSArray* controllers = [NSArray arrayWithObjects:vc1, vc2, nil]; 
    tabBarController.viewControllers = controllers; 

    window.rootViewController = tabBarController; 
} 

,您可以通过在tabBarController的阵列viewControllers的加入控制器动态添加控制器了。