Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

SimonBS

macrumors regular
Original poster
Dec 30, 2009
202
0
I need to present a modal view controller before showing a split view controller. I need this because the user will have to log in.

I have read answers on this forum suggesting that the modal view controller should be presented from the AppDelegate but when trying to do so, nothing happens.

I have set up my view controller in the same storyboard as the rest of my interface is in and I have given the view controller the identifier `loginViewController`. I am trying to show the view controller in the AppDelegate like this:

Code:
- (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 so, nothing happens. No errors, no modal view controller, no nothing. The application just shows my split view controller.

Can anybody tell me how I can show a modal view controller before showing the split view controller?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.