-1

Following code works to call root controller from AppDelegate. However it does not work when I put it in a separate login View Controller. After a successful login, I want to load the regular View Controller. However within the login VC, it does not load main view controller. It continues to show login VC although an NSLog in the method reveals it is getting fired.

Thanks for any suggestions on right way to load root view controller from another VC.

    - (void)presentMainInterface
    {
NSLog(@"presenting main interface");
        self.window.rootViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateInitialViewController];
    }
user1904273
  • 4,562
  • 11
  • 45
  • 96

1 Answers1

3

Try this

UIWindow *window =  [[[UIApplication sharedApplication] windows] firstObject];
window.rootViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateInitialViewController];
Leo
  • 24,596
  • 11
  • 71
  • 92