2013-08-16 147 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的加入控制器動態添加控制器了。