【问题标题】:UIModalPresentationCurrentContext and willRotateToInterfaceOrientationUIModalPresentationCurrentContext 和 willRotateToInterfaceOrientation
【发布时间】:2013-03-27 17:18:33
【问题描述】:

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

所以发生的情况是,当设备方向改变而弹出视图控制器以模态方式呈现时,willRotateToInterfaceOrientation:didRotateFromInterfaceOrientation: 方法不会被调用。 supportedInterfaceOrientations 被称为 amd 返回好的值。旋转已启用,支持的方向已正确设置。如果我将 'modalPresentationStyle' 更改为默认值,弹出窗口实际上会起作用,一切正常,除了显然我没有看到后面的主视图控制器。

我应该补充一点,主视图控制器只支持纵向,而它上面的弹出窗口支持所有方向。

在 iOS 5.1 设备上,willRotatedidRotate 方法被正确调用。只有在 iOS 6 设备上它们才不是。

是否有人遇到过类似的问题或已经需要在单方向视图控制器上方模态显示透明的多方向视图控制器?

【问题讨论】:

  • 我在想要在 iOS6+ 上工作的应用程序中遇到了同样的问题。你有没有找到解决方案?

标签: ios uiviewcontroller uiinterfaceorientation autorotate


【解决方案1】:

这样做...

- (BOOL)shouldAutorotateToInterfaceOrientation: (UIInterfaceOrientation) interfaceOrientation {
    UIDevice* thisDevice = [UIDevice currentDevice];
    if (thisDevice.userInterfaceIdiom == UIUserInterfaceIdiomPad)
    {
        return true;
    }
    else
    {
        return interfaceOrientation == UIDeviceOrientationLandscapeLeft;
    }
}

【讨论】:

    猜你喜欢
    • 2012-09-26
    • 2013-10-27
    • 1970-01-01
    • 1970-01-01
    • 2013-03-30
    • 2010-12-07
    • 1970-01-01
    • 1970-01-01
    • 2011-11-14
    相关资源
    最近更新 更多