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.
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.
I ran recently into the same issue. However, the solution provided did not work out for me.
The reason was that I used a "push" segue to display my login view controller (which was embedded inside a navigation controller). Changing the style of the segue from "push" to "modal" did the trick for me. Apparently, it is not possible to initiate a "push" segue from within a tab bar controller but only from within a navigation controller.
Furthermore, I did not put the line
[self performSegueWithIdentifier:@"LoginSegue sender:self];
in the method didFinishLaunchingWithOptions:didFinishLaunchingWithOptions:
of the app's delegate, but rather in the method viewDidAppear:
. Doing so, I did not need the following line of code:
[self.window makeKeyAndVisible];
Hope this is useful to others.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With