Ios iPad模态视图控制器在屏幕上旋转界面

Ios iPad模态视图控制器在屏幕上旋转界面,ios,objective-c,ipad,modalviewcontroller,interface-orientation,Ios,Objective C,Ipad,Modalviewcontroller,Interface Orientation,我正在开发的一个应用程序存在如下问题: [self.rootViewController presentModalViewController:viewController animated:YES completition:nil]; 应用程序的窗口有一个rootViewController,它被设置为UIViewController的自定义类(MenuViewController)。此视图控制器具有自己的rootViewController属性。每当发生这种情况时(真正简短的代码版本):

我正在开发的一个应用程序存在如下问题:

[self.rootViewController presentModalViewController:viewController animated:YES completition:nil];
应用程序的窗口有一个
rootViewController
,它被设置为
UIViewController
的自定义类(
MenuViewController
)。此视图控制器具有自己的
rootViewController
属性。每当发生这种情况时(真正简短的代码版本):

现在,这个
菜单viewcontroller
可以在其rootViewController的顶部显示一个模态视图控制器

我是这样做的:

[self.rootViewController presentModalViewController:viewController animated:YES completition:nil];
在这里之前一切看起来都很好。现在在iPad上,每当我从我的模态视图控制器调用
[self.presentingViewController dismissViewControllerAnimated:YES completion:nil]
时,它下面的界面都会旋转到相同的方向(即
UIInterfaceOrientation和scapeLeft
)无论显示视图控制器时初始方向是什么

总之,我的观点是:

Window
   |
   - Menu View Controller
      |
      - Root View Controller
          |
          - Modal view controller

有人知道我怎么解决这个问题吗?iPhone上不会出现这种情况。

我觉得在iPad上,你的
MenuViewController
rootViewController
支持多种界面方向,而在iPhone上则不支持。这是猜测,因为你没有说过这件事


如果是这种情况,并且rootViewController确实支持多个接口方向,那么修复方法是覆盖
-supportedInterfaceOrientations
并返回纵向,这似乎是您所建议的您想要的。

实际上,我已经通过实现
preferredInterfaceOrientationForPresentation
并返回
self.interfaceOrientation
解决了这个问题。如果你问我,我会觉得很奇怪,但它确实起到了作用!:)