ive got a navigation controller with a simple view as its rootsview. it has a button connected via a seque to a second view controller. The seque cause the second view controller to show up modal. If a condition isnt true i directly want to show up this second view controller after application launched.
I tried out a lot of code but it just wont work. Here is a screenshot of my scene :
Any Ideas how to do this?
I tried the following :
UIStoryboard *storybord = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
UINavigationController *vc = [storybord instantiateInitialViewController];
[[vc.viewControllers objectAtIndex:0] performSegueWithIdentifier:@"simple" sender:self];
but i got the following error message :
Attempt to present
<UINavigationController: 0x71b2ab0>on<UINavigationController: 0x71b12c0>whose view is not in the window hierarchy!
I assume you’re trying that sample code from app delegate? You need to make sure you don’t try to perform the segue until after the first view is loaded. Coincidentally, if you wait until then, its much easier as all you need to do the
performSegueWithIdentifier. Thus, in theviewDidLoadof the first view controller, e.g.:Obviously, replace
bShouldAutomaticallyPerformSegueToSecondVCwith whatever logic is appropriate to determine when you automatically want to go to the second view controller.