【问题标题】:How to handle rotation for a UIViewController that isnt on top of UINavigationController stack?如何处理不在导航控制器堆栈顶部的视图控制器的旋转?
【发布时间】:2011-07-22 16:26:21
【问题描述】:

我在 UINavigationController 中有一个根 UIViewController (VC1),它通过在 willRotateToInterfaceOrientation: 方法中手动调整其视图/子视图帧来处理旋转。如果根 UIViewController 是活动视图控制器,则旋转工作正常,基本上位于堆栈顶部。

当我将另一个 UIViewController (VC2) 推送到 NavigationController 时,就会出现问题。然后我旋转VC2,它工作正常。但是,当我弹出 VC2 时,问题是 VC1 没有旋转到正确的方向,它的 willRotateToInterfaceOrientation: 方法也没有被调用? VC1 中的 shouldAutorotateToInterfaceOrientation: 方法被调用,仅此而已。

然后我的问题是我应该如何确保我的 UIViewController VC1 已经针对这种情况的当前方向进行了更新??

【问题讨论】:

    标签: iphone ipad uiviewcontroller uinavigationcontroller rotation


    【解决方案1】:

    我解决此问题的方法是检查 viewWillAppear: 以查看现在的方向是否与调用 viewDidDisappear 时不同。如果是这样,我调用代码来布局视图。

    要采用这种方法,首先将负责将视图布局为_layoutViews 之类的代码,可以简单地在viewWillAppearwillRotateToInterfaceOrientation: 中根据需要调用它。

    【讨论】:

      猜你喜欢
      • 2015-05-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多