2014-02-21 35 views
1

我有两个导航控制器TabBarController作为附加图像。 如果我的应用程序第一次运行应该打开第二视图控制器。在启动时打开SecondViewController insted FirstViewController

对于导航控制器我用下面的代码:

UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Main_iPhone" bundle:nil]; 

    cysViewController *cvc =[sb instantiateViewControllerWithIdentifier:@"cysViewController"]; 
    questionViewController *qvc = [sb instantiateViewControllerWithIdentifier:@"questionViewController"]; 
    UINavigationController *nav = (UINavigationController *) self.window.rootViewController; 
    nav.viewControllers = [NSArray arrayWithObjects:cvc,qvc, nil]; 
    [(UINavigationController *)self.window.rootViewController popToViewController:qvc animated:NO]; 

但tabBarController我不知道该怎么做。

my controllers

+1

尝试setSelectedViewController: – prasad

回答

0

您可以通过改变selectedIndex值更改选定的指数。

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions { 
    UITabBarController *tabController = (UITabBarController *)self.window.rootViewController; 
    tabBarController.selectedIndex = 1; 
} 
+0

thx,它解决了我的问题:) – Nizzre

相关问题