【问题标题】:PresentModalViewController from within UISplitViewController: weird behavior in landscape modeUISplitViewController 中的 PresentModalViewController:横向模式下的奇怪行为
【发布时间】:2011-01-07 20:59:37
【问题描述】:

我一直在使用 PresentModalViewController 并且从未遇到任何问题。但是,当从 UISplitViewController 托管的任何控制器中显示模态控制器时,我会遇到奇怪的方向错误。

在我的表格视图(UISplitView 的根控制器)中,当一个单元格被触摸时,我调用:

MyController oModal = new MyController();
oModal.ModalPresentationStyle = UIModalPresentationStyle.FormSheet;
oModal.ModalTransitionStyle = UIModalTransitionStyle.CrossDissolve;
this.PresentModalViewControll(oModal, true);

如果 iPad 处于纵向模式,则一切正常。但是,如果它是横向的,模态控制器会淡入,但它的方向不正确。然后,在淡入完成后,它突然翻转 90 度并调整到正确的方向。 我已经覆盖了 ShouldAutoRotateToInterfaceOrientation(),所以这不可能。

想法?

勒内

【问题讨论】:

    标签: cocoa-touch xamarin.ios


    【解决方案1】:

    我遇到了这个并有一个解决方法,而不是真正的解决方案。问题是您从(在您的代码“this”中)呈现模态控制器的 UIViewController 对其属性 interfaceOrientation 的响应方向不正确。它发生在我身上,我不确定为什么。解决方法是为您的 UIViewController(“this”)中的属性添加一个自定义 getter,如下所示:

    -(UIDeviceOrientation)interfaceOrientation
    {
        return [[UIDevice currentDevice] orientation];
    }
    

    我的想法来自this post。我认为问题在于视图控制器没有正确嵌入到视图控制器层次结构中,但还没有弄清楚如何。希望这可以帮助。

    【讨论】:

    • 但即使我从拆分控制器托管的详细信息控制器中呈现它也是不正确的。那是我不明白的。我的意思是,细节控制器正确旋转,为什么模态不?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-10
    • 1970-01-01
    • 2012-07-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多