在app delegate中更改根导航控制器

时间:2014-04-22 17:17:33

标签: ios abcustomuinavcontroller

我正在使用ABCustomUINavigationController,我想像这样初始化我的故事板,但我总是得到错误

LoginViewController *loginViewController = [[LoginViewController alloc] init] ;
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        loginViewController = [[LoginViewController alloc] initWithNibName:@"LoginViewController" bundle:nil];
    } else {
        loginViewController = [[LoginViewController alloc] initWithNibName:@"LoginViewControllerPad" bundle:nil];
    }

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    //self.window.rootViewController = [[FlipSquaresNavigationController alloc] initWithRootViewController:self.viewController];
    self.window.rootViewController = [[FlipSquaresNavigationController alloc] initWithRootViewController:loginViewController];
    [self.window makeKeyAndVisible];

另一次尝试

    NSString *nibName = [[NSString alloc] init] ;
    NSString *storyBoard = [[NSString alloc] init] ;

    if ( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad ) {
        //iPad
        nibName = @"LoginViewControllerPad" ;
        storyBoard = @"Main_iPad" ;
    }else {
        //iPhone
        nibName = @"LoginViewController" ;
        storyBoard = @"Main_iPhone" ;
    }

//    UINavigationController *navigationController = (UINavigationController *)self.window.rootViewController;
    UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:storyBoard bundle: nil];
    LoginViewController *loginViewController = (LoginViewController *)[mainStoryboard instantiateViewControllerWithIdentifier: nibName];

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.
    //self.window.rootViewController = [[FlipSquaresNavigationController alloc] initWithRootViewController:self.viewController];
    self.window.rootViewController = [[FlipSquaresNavigationController alloc] initWithRootViewController:loginViewController];
2014-04-22 19:13:27.744 Matching[791:60b] I restkit:RKLog.m:33 RestKit logging initialized...
2014-04-22 19:13:28.218 Matching[791:60b] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Could not load NIB in bundle: 'NSBundle  (loaded)' with name 'LoginViewController''
*** First throw call stack:
(0x2f457f4b 0x397e76af 0x2f457e8d 0x31f29e39 0x31e8b917 0x31ced389 0x31bcf1bd 0x31bcf139 0x31c46dd5 0x31c4574d 0x31c4529b 0x31c45223 0x31c451bb 0x31c3dcb9 0x31bd0db7 0x31c44f09 0x31c449d5 0x31bd5f95 0x31bd34db 0x31c3e08d 0x91e29 0x31c3b2ff 0x31c3ad4f 0x31c35353 0x31bd041f 0x31bcf721 0x31c34b3d 0x3406b70d 0x3406b2f7 0x2f4229df 0x2f42297b 0x2f42114f 0x2f38bc27 0x2f38ba0b 0x31c33dd9 0x31c2f049 0xbc49d 0x39cefab7)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

0 个答案:

没有答案