I need to present a modal view controller before displaying a controller with a split view. I need this because the user will have to log in.
I read the answers in this forum, suggesting that the modal view controller be presented from AppDelegate, but nothing happens when I try to do this.
I installed my view controller in the same storyboard as the rest of my interface, and I gave the view controller the loginViewController identifier. I am trying to show a view controller in AppDelegate as follows:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { UISplitViewController *splitViewController = (UISplitViewController *) self.window.rootViewController; UINavigationController *navigationController = splitViewController.viewControllers.lastObject; splitViewController.delegate = (id) navigationController.topViewController; UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPad" bundle:nil]; LoginViewController *lvc = (LoginViewController *) [storyboard instantiateViewControllerWithIdentifier:@"loginViewController"]; lvc.modalPresentationStyle = UIModalPresentationFullScreen; [splitViewController presentModalViewController:lvc animated:YES]; } [_window makeKeyAndVisible]; return YES; }
When I do this, nothing happens. No errors, no modal representation controller, nothing. The app just shows my split view controller.
Can someone tell me how can I show the modal view controller before displaying the controller with split view?
source share