Question

I've encountered this bad internal state of UIView Controller:
Sometimes, the presented vc removed from screen, but remains on its presentingVC, as the vc.presentedViewController.

In this state you cannot present any other vc before you dismiss the previous invisible presented vc.

Was it helpful?

Solution

The problem occurs when calling [UIWindow makeKeyAndVisible],
while there's a presented vc.

You can dismiss and present the modal immediately (no UI glitches):

    [window makeKeyAndVisible];

    if (myCurrentVC.presentedViewController != nil) {
            UIViewController *presented = myCurrentVC.presentedViewController;
            [myCurrentVC dismissViewControllerAnimated:NO completion:nil];
            [myCurrentVC presentModalViewController:presented animated:NO];
    }

Works great for me

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top