UIModalPresentationCurrentContext和willRotateToInterfaceOrientation
问题描述:
我有一个模态视图控制器(让我们称之为弹出视图控制器)呈现在我的主视图控制器。在某些时候,我需要看到弹出窗口后面的主视图控制器。因此,在呈现弹出视图控制器之前,我将modalPresentationStyle
属性设置为UIModalPresentationCurrentContext
。UIModalPresentationCurrentContext和willRotateToInterfaceOrientation
所以会发生什么情况是,当弹出式视图控制器模态呈现时设备方向发生变化时,将不会调用willRotateToInterfaceOrientation:
和didRotateFromInterfaceOrientation:
方法。被称为amd的supportedInterfaceOrientations
返回良好的价值。旋转已启用,支持的方向已正确设置。如果我将'modalPresentationStyle'更改为默认值,一切正常,除非很明显我没有看到主视图控制器。
我应该补充说,主视图控制器只支持portait,而上面的弹出框支持所有的方向。
在iOS 5.1设备上,正确调用willRotate
和didRotate
方法。只有在iOS 6设备上它们不是。
有没有人遇到过类似的问题,或者已经需要在单个方向视图控制器上以模态方式显示透明的多方向视图控制器?
答
操作方法......
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation {
UIDevice* thisDevice = [UIDevice currentDevice];
if (thisDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad)
{
return true;
}
else
{
return interfaceOrientation == UIDeviceOrientationLandscapeLeft;
}
}
我在一个应用程序,我想在iOS6的+工作得到了同样的问题。你有没有找到这个解决方案? – dvkch 2014-10-02 14:30:49