popViewController 不会自动旋转回允许的方向
我有两个 UIViewController,“A”和“B”,其中“A”覆盖 shouldAutorotateToInterfaceOrientation 以针对 UIInterfaceOrientationPortrait 返回 YES,而“B”则针对所有方向返回 YES。在我的示例中,“A”是根导航视图控制器,然后我将 PushViewController 用于“B”。之后,我将设备旋转到横向,这成功地自动旋转“B”,然后我弹出“B”(后退按钮或通过 popViewController)返回到“A”。
当针对 iPhone OS 3.1.3 时,“A”按预期返回到纵向。当针对 iPhone OS 3.2 时,我有两个副作用:
- “A”横向显示。
- 即使现在显示“A”,导航栏也不会更新。导航栏仍然显示“B”的项目。只有在再次尝试返回/弹出一次后,导航栏才会以动画方式显示“A”的项目。如果我尝试再次按“B”并返回,则必须在导航栏动画显示“A”的项目之前弹出两次。在这些“中间弹出”期间,“A”的视图保持显示。
在研究这个问题时,我看到其他答案建议手动执行旋转([UIDevice setOrientation] 或通过转换),但这无助于理解问题是什么,特别是为什么它在两个操作系统之间的行为不同。
所以我的问题是:UINavigationController 堆栈上的所有 UIViewController 都必须支持完全相同的方向吗?如果没有,那么我需要做些什么才能使其像 OS 3.1.3 那样运行?
I have two UIViewControllers, "A" and "B", where "A" overrides the shouldAutorotateToInterfaceOrientation to return YES for UIInterfaceOrientationPortrait, and "B" returns YES for all orientations. In my example "A" is the root navigation view controller, and I then use pushViewController for "B". After that I rotate the device into landscape, which successfully autorotates "B", then I pop "B" (back button or via popViewController) to return to "A".
When targetting iPhone OS 3.1.3, "A" returns to the portrait orientation as expected. When targetting iPhone OS 3.2, I have two side-effects:
- "A" is displayed in landscape.
- The navigation bar does not update even though "A" is now displayed. The navigation bar still shows the items for "B". Only after trying to go back/pop one more time will the navigation bar animate to show the items for "A". If I instead attempt to push "B" again and go back, I have to pop twice before the navigation bar animates to show the items for "A". During these "intermediate pops" the view for "A" remains displayed.
While researching this issue, I have seen other answers suggesting performing the rotation manually ([UIDevice setOrientation] or via a tranformation), however this does not help understand what the problem is, especially why it behaves differently between the two OS's.
So my question is: must all of my UIViewControllers on the UINavigationController stack support exactly the same orientations going forward? And if not, then is there something that I need to do to make it behave as it did for OS 3.1.3?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看来较新的操作系统要求 UINavigationController 堆栈中的所有 UIViewController 支持相同的方向集。
It would appear that the newer OS's require all UIViewControllers in the UINavigationController stack to support the same set of orientations.
我有同样的问题,我在此链接上找到了答案: UINavigationController 导航堆栈问题在横向模式下,我的一个视图控制器在shouldAutorotateToInterfaceOrientation上没有返回YES。
I have the same problem and I found the answer on this link: UINavigationController navigation stack problems in landscape mode one of my view controllers was not return YES on shouldAutorotateToInterfaceOrientation.