UINavigationController 模式对话框的旋转问题
我有一个具有以下结构的应用程序:
UIWindow
-- GlobalNavigationController.view (subclasses UIViewController)
-- UIView
-- UINavigationController.view
GlobalNavigationController 将所有旋转和生命周期事件(viewWillAppear、willRotateToInterfaceOrientation 等)转发到导航控制器。
一切都运行良好,直到您:
- 打开模式对话框
- 旋转到横向(或另一个方向)
- 关闭对话框。
此时,UINavigationController 中的底层视图似乎没有被告知某些旋转事件。
您会得到如下视图:
有什么想法吗? 谢谢
I've got an app with the following structure:
UIWindow
-- GlobalNavigationController.view (subclasses UIViewController)
-- UIView
-- UINavigationController.view
GlobalNavigationController forwards all rotation and lifecycle events (viewWillAppear, willRotateToInterfaceOrientation, etc) to the navigation controller.
Everything works really well, until you:
- Open a modal dialog
- Rotate into landscape (or to another orientation)
- Close the dialog.
At this point, it seems that the underlying views in UINavigationController were not informed about some of the rotation events.
You get views like this:
Any idea?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
原来是导航控制器没有设置parentViewController属性的问题。喜欢未记录的陷阱...
简单的解决方案是将其放在导航控制器初始化之后:
Props to PrimaryFeather 的想法:
模态视图控制器无法在横向模式下启动
It turned out to be a problem where the navigation controller did not have a parentViewController property set. Love the undocumented gotchas...
The simple solution was putting this after the navigation controller initialization:
Props to PrimaryFeather for the idea:
Modal View Controller Won't Start in Landscape Mode
在您的模态视图控制器中,尝试设置以下内容:
这会发送视图旋转到其父级的消息,即呈现模态窗口的视图
In your modal view controller, try setting up the following:
This sends the message that the view rotated to its parent, which is the view that presented the modal window
我在开发的应用程序中遇到了类似的问题。事实证明,我的问题是我没有正确指定我的控件(例如顶部工具栏)如何增长和拉伸。
如果问题不是代码问题,请查看IB,看看是否定义了自动增长等。
I encountered a similar issue with an app I was working on. It turns out, my problem was I did not correctly specify how my control (e.g. top tool bar) were to grow and strech.
If the issue is not a code issue, take a look at IB and see if you have defined autogrow, etc.