开发者

How can I know if a ModalViewController is being shown?

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开发者_Go百科 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!


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


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];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜