Sebastian Boldt Sebastian Boldt - 1 month ago 5
Objective-C Question

Getting Initial View Controller from Storyboard inside the App Delegate

I am trying to access the initial viewcontroller of my storyboard. It is a navigation controller which is wired up to a second viewcontroller via a seque. So after application did finish launching i want to directly show viewController that is connected through the segue. I tried it out with code like this but it doesnt work ...

UINavigationController *navController = (UINavigationController*)self.window.rootViewController;
[navController.topViewController performSegueWithIdentifier:@"showLoginScreen" sender:self];

What i am doing wrong ?


Be sure you have tick marked the

is initial ViewController

option for UINavigationController in storyBoard

UIStoryboard* storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UINavigationController * myStoryBoardInitialViewController = [storyboard instantiateInitialViewController];