Question

I override -orientationChanged in my main ViewController to push ModalViewController A when the device is in landscape mode. When placed back in portrait mode, ModalViewController A is dismissed. However, there are other cases (after button touches) where ModalViewControllers B, C, or D are shown. When those are showing, if the device is turned landscape and turned back, ModalViewController B C or D is dismissed, inappropriately.

I can verify that -orientationChanged on my main ViewController is being messaged even when a ModalViewController is shown. Is there a condition I can add to my -orientationChanged method to bypass that code when ModalViewController B C or D is being shown?

Thank you!

Was it helpful?

Solution

You can check if the modalViewController property in your main viewcontroller is one of your view controllers.

OTHER TIPS

You can use this code to find what is the last ModalViewController.

UIViewController *leafController = self;
while(true) {
    if (leafController.modalViewController) {
        leafController = leafController.modalViewController;
        continue;
    }
    break;
}
[leafController presentModalViewController:showController animated:YES];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top