我有一个模态视图 Controller (我们称它为弹出 View Controller )显示在我的主视图 Controller 上。在某些时候,我需要看到弹出窗口后面的主视图 Controller 。因此,在显示弹出 View Controller 之前,我将 modalPresentationStyle
属性设置为 UIModalPresentationCurrentContext
。
因此,当弹出 View Controller 以模态呈现时设备方向发生变化时,willRotateToInterfaceOrientation:
和 didRotateFromInterfaceOrientation:
方法不会被调用。 supportedInterfaceOrientations
调用 amd 返回良好的值。旋转已启用,支持的方向已正确设置。如果我将“modalPresentationStyle”更改为默认值,弹出式 conIt 实际上有效,一切正常,除了显然我没有看到后面的主视图 Controller 。
我应该补充一点,主视图 Controller 仅支持纵向,而其上方的弹出窗口支持所有方向。
在 iOS 5.1 设备上,willRotate
和 didRotate
方法被正确调用。只有在 iOS 6 设备上它们才不是。
有没有人遇到类似的问题或已经需要在单方向 View Controller 上方模态显示透明的多方向 View Controller ?
最佳答案
这样做...
- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation {
UIDevice* thisDevice = [UIDevice currentDevice];
if (thisDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad)
{
return true;
}
else
{
return interfaceOrientation == UIDeviceOrientationLandscapeLeft;
}
}
关于ios - UIModalPresentationCurrentContext 和 willRotateToInterfaceOrientation,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15665245/