Search code examples
authenticationios6uisplitviewcontroller

ios6 - How to present a login screen before uisplitviewcontroller?


I'm developing an app with a UISplitViewController. However, I need to show a Login Screen before the UISPlitViewController. I created a simple UIViewController and I created a segue from the DetailViewController to the new UIViewController. I also created a ViewDidAppear in DetailViewController who calls the segue.

- (void)viewDidAppear:(BOOL)animated

{ [super viewDidAppear:animated];

       [self performSegueWithIdentifier:@"loginSegue" sender:self];

}

I got this error: "has no segue with identifier 'loginSegue'"

Are there any great way to do this?

Thanks


Solution

  • I found the solution myself. The solution is: call a modal inside applicationDidBecomeActive in AppDelegate. Example:

    static dispatch_once_t onceToken;
    
    dispatch_once( &onceToken, ^
                  {
                      UIStoryboard *storyboard = self.window.rootViewController.storyboard;
                      LoginViewController* launchViewController = [storyboard instantiateViewControllerWithIdentifier:@"LoginViewController"];
                      [self.window.rootViewController presentViewController:launchViewController animated:NO completion:NULL];
    
                      launchViewController.managedObjectContext = self.managedObjectContext;
                  } );