如何知道是否显示ModalViewController?

ed9*_*133 5 iphone uiviewcontroller modalviewcontroller

我在主ViewController中覆盖-orientationChanged,以便在设备处于横向模式时推送ModalViewController A. 当以纵向模式放回时,ModalViewController A被解除.但是,还有其他情况(按钮触摸后),其中显示了ModalViewControllers B,C或D. 当这些显示时,如果设备被转向横向并向后转,ModalViewController BC或D被不适当地解雇.

即使显示了ModalViewController,我也可以验证我的主ViewController上的-orientationChanged是否正在被消息.在显示ModalViewController BC或D时,是否存在我可以添加到-orientationChanged方法以绕过该代码的条件?

谢谢!

Elf*_*red 6

您可以检查主viewcontroller中的modalViewController属性是否是您的一个视图控制器.

  • 谢谢,这很有效.我使用了条件:if([self.modalViewController isMemberOfClass:[UINavigationController class]])... (2认同)