ios - UIModalPresentationCurrentContext 和 willRotateToInterfaceOrientation

标签 ios uiviewcontroller uiinterfaceorientation autorotate

我有一个模态视图 Controller (我们称它为弹出 View Controller )显示在我的主视图 Controller 上。在某些时候,我需要看到弹出窗口后面的主视图 Controller 。因此,在显示弹出 View Controller 之前,我将 modalPresentationStyle 属性设置为 UIModalPresentationCurrentContext

因此,当弹出 View Controller 以模态呈现时设备方向发生变化时,willRotateToInterfaceOrientation:didRotateFromInterfaceOrientation: 方法不会被调用。 supportedInterfaceOrientations 调用 amd 返回良好的值。旋转已启用,支持的方向已正确设置。如果我将“modalPresentationStyle”更改为默认值,弹出式 conIt 实际上有效,一切正常,除了显然我没有看到后面的主视图 Controller 。

我应该补充一点,主视图 Controller 仅支持纵向,而其上方的弹出窗口支持所有方向。

在 iOS 5.1 设备上,willRotatedidRotate 方法被正确调用。只有在 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/

相关文章:

ios - 转换在 drawRect 中绘制的内容

ios - 对从 NSDictionary 创建的 NSMutableArray 进行排序

ios - 只允许一个 UIViewController 有多个方向

iphone - iOS 6 旋转不起作用

objective-c - 将图像(或其他资源)添加到 Mac 或 iOS 框架

ios - favicon - 简单但相当完整的策略

ios - 执行 segue 后无法更改标签文本

ios - 我如何找出哪个 segue 在 unwind segue 中称为目的地?

ios - 每个 ViewController 创建只调用一次的回调

ios - 如何设置iOS设备仅面向横向?