【问题标题】:UINavigation Controller and AutorotationUINavigation 控制器和自动旋转
【发布时间】:2010-06-04 16:32:49
【问题描述】:

我正在使用 UINavigationController 来推送和弹出视图。导航栏已隐藏。

我有 RootViewController,它被设置为自动旋转。当它可见时它工作得很好。 我也有 GalleryViewController。它通过返回 no 来禁用自动旋转。


我的问题是,当 GalleryViewController 在导航堆栈上时,RootViewController 停止响应它的自动旋转事件。


如果我处于纵向模式,并且我旋转设备(在查看 GalleryViewController 时)然后点击返回按钮,它会将 GalleryViewController 从堆栈中弹出并显示 RootViewController,但 RootViewController 并没有按照应有的方式改变旋转。

我坚持使用 -viewWillAppear 方法并检查 UIDevice 方向的状态。它为我提供了正确的设备方向。

顺便说一句,我也尝试在 GalleryViewController 中启用自动旋转。然后它会正确旋转视图,但仍然不旋转 RootViewController。


似乎在使用导航控制器时,只有栈顶被旋转。


问题:由于设备在调用 -viewWillAppear 时知道它处于正确的旋转状态,我可以强制它以某种方式更新吗??

-标记

【问题讨论】:

    标签: iphone uinavigationcontroller autorotate


    【解决方案1】:

    不要只返回 YES,而是在 RootViewController 中返回 (interfaceOrientaion == UIInterfaceOrientationPortrait || interfaceOrientation == UIInterfaceOrientationLandscapeLeft || 等等...)。

    在 GalleryViewController 中只返回一个我们认为是默认的方向。

    完成后 - 一切都应该如你所愿。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-08-18
      • 1970-01-01
      • 1970-01-01
      • 2015-08-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多