问题描述
|
我有一个具有以下结构的应用程序:
UIWindow
-- GlobalNavigationController.view (subclasses UIViewController)
-- UIView
-- UINavigationController.view
GlobalNavigationController将所有旋转和生命周期事件(viewWillAppear,willRotateToInterfaceOrientation等)转发到导航控制器。
一切都会很好,直到您:
打开模式对话框
旋转到风景(或其他方向)
关闭对话框。
此时,似乎没有通知UINavigationController中的基础视图一些旋转事件。
您将获得如下视图:
任何想法?
谢谢
解决方法
在模态视图控制器中,尝试设置以下内容:
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[self.parentViewController didRotateFromInterfaceOrientation:fromInterfaceOrientation];
}
这会将视图旋转到其父级的消息发送,该父级是显示模式窗口的视图
,我正在使用的应用程序遇到类似的问题。事实证明,我的问题是我没有正确指定控件(例如顶部工具栏)的增长和伸展方式。
如果问题不是代码问题,请查看IB,看看是否已定义自动增长等。
,原来这是导航控制器未设置parentViewController属性的问题。爱无证的陷阱...
一个简单的解决方案是将其放在导航控制器初始化之后:
[_navigationController setValue:self forKey:@\"_parentViewController\"];
支持PrimaryFeather的想法:
Modal View Controller无法在横向模式下启动