UINavigationController 中的 UIViewController 未按预期旋转
我有一个 UINavigationController,其根 UIViewController 仅支持纵向方向。当用户按下按钮时,第二个 UIViewController 被加载并推入堆栈,这个视图控制器(我们称之为 secondaryViewController)仅支持横向。
通常会发生的情况是界面在转换到 secondaryViewController 期间旋转,但尽管在 secondaryViewController 上调用了 shouldAutorotateToInterfaceOrientation: ,但这种情况不会发生。一旦我在显示第二个视图控制器时手动倾斜设备,它就会按预期旋转,并且当切换回第一个 UIViewController 时,它会按预期旋转回纵向。
为了测试第一个 UIViewController 允许的界面方向是否对进程有任何影响,我设置了 return YES;然而,对于那里的所有接口,问题仍然存在。我还阅读了有关该主题的技术问答,但是根据此文档,一切都应该没问题,UINavigationController 是窗口的唯一子视图。
我完全以编程方式创建了 secondaryViewController (覆盖 loadView),并且这个特殊情况之前在其他应用程序中工作过。有人知道我可能做错了什么吗?
I have a UINavigationController who's root UIViewController only supports Portrait orientation. When the user presses a button a second UIViewController gets loaded and pushed onto the stack, this view controller, let's call it secondViewController, only supports landscape orientation.
Usually what would happen is that the interface rotates during the transition to secondViewController, but this doesn't happen despite shouldAutorotateToInterfaceOrientation: getting called on secondViewController. Once I tilt the device manually when secondViewController is displayed it rotates as expected and when switching back to the first UIViewController it rotates back to portrait as it should.
To test whether the allowed interface Orientations of the first UIViewController have any influence on the process I set a return YES; for all the interfaces there, however, the problem persisted. I also read the technical Q&A on the subject but according to this doc everything should be fine, the UINavigationController is the only subview of the window.
I create secondViewController completely programmatically (overwriting of loadView) and had this particular case working before in other apps. Does anybody have an idea what I might be doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
显然,更改不会自动发生,以下给出了必要的“推动”:
Apparently the change doesn't happen automatically, the following gives the neccessary "push":