Search code examples
ios5storyboardtabbarcontroller

how to segue a view controller on app load using tabbarcontroller


I am using a tabbarcontroller as the root view controller. Unfortunately, using the new storyboard functionality, it is proving difficult to segue a view controller - Login Page - on the app load.

I am using the below code:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

    UITabBarController *tabBarController = (UITabBarController *)self.window.rootViewController;

    [tabBarController performSegueWithIdentifier:@"loginPage" sender:self];

The segue is set up properly. I went into one of the tabs view controllers and made an IBAction and it successfully segued. Thanks in advance.


Solution

  • Ran into this same issue today. I had to call:

    [self.window makeKeyAndVisible];
    

    before

    [self.window.rootViewController performSegueWithIdentifier:@"LoginView" sender:self];
    

    So I'm assuming that when using storyboards the makeKeyAndVisible happens after didFinishLaunchinWithOptions: returns. So when were calling the segue its happening on a view thats not onscreen.