【问题标题】:ViewController has wrong orientation after Landscape-only has been popped仅横向弹出后 ViewController 的方向错误
【发布时间】:2011-01-06 19:41:35
【问题描述】:

在基于导航的应用程序中,LandscapeViewController 仅支持横向模式(所有其他模式都支持这两种模式)。我还有一个“加载屏幕”,建议用户在继续之前旋转手机。这样我可以确保当我的横向视图加载时,它处于横向模式。

当我将手机旋转到纵向模式同时仍显示 LandscapeVC 时出现问题。我按下后退导航按钮向上导航一级(到支持横向和纵向模式的 VC),但即使手机处于纵向模式,上一级也会以横向模式显示。我想这是因为当我离开这个视图时我处于纵向模式,然后我在另一个视图中旋转手机,所以这个视图没有收到通知。如果我继续将手机旋转到其他横向模式(假设 LandscapeVC 加载在其右侧,所以我将上部 VC 从纵向旋转到左侧横向模式),它将更新。

我的问题是:我如何通知这个上视图手机被旋转了,所以当用户将手机置于竖屏模式后向上时,上视图正确显示?

【问题讨论】:

    标签: iphone uiviewcontroller rotation


    【解决方案1】:

    请试试这个,

    这可能会对你有所帮助。

    一切顺利

    - (BOOL) shouldAutorotateToInterfaceOrientation:UIInterfaceOrientation)interfaceOrientation {
        if (interfaceOrientation == UIInterfaceOrientationPortrait)
            return NO;
        if (interfaceOrientation == UIInterfaceOrientationLandscapeRight || interfaceOrientation == UIInterfaceOrientationLandscapeLeft )
            return YES; 
        return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }
    

    【讨论】:

      【解决方案2】:

      您从堆栈中弹出子视图并返回到前一个视图(当前保持横向,您希望纵向),您可以尝试将其发送到setNeedsLayout 选择器。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-01-31
        • 1970-01-01
        • 2013-05-24
        • 2011-05-16
        相关资源
        最近更新 更多