【问题标题】:UINavigationController rotation problem with modal dialog模态对话框的 UINavigationController 旋转问题
【发布时间】:2011-05-25 17:54:01
【问题描述】:

我有一个具有以下结构的应用:

UIWindow
   -- GlobalNavigationController.view (subclasses UIViewController)
      -- UIView
      -- UINavigationController.view

GlobalNavigationController 将所有旋转和生命周期事件(viewWillAppear、willRotateToInterfaceOrientation 等)转发到导航控制器。

一切都很好,直到你:

  1. 打开模式对话框
  2. 旋转成横向(或其他方向)
  3. 关闭对话框。

此时,UINavigationController 中的底层视图似乎没有被告知某些旋转事件。

你会得到这样的视图:

有什么想法吗? 谢谢

【问题讨论】:

  • 更新:当显示模式对话框时,不会在 GlobalNavigationController 中调用 willRotateToInterfaceOrientation

标签: iphone uinavigationcontroller modal-dialog landscape


【解决方案1】:

在您的模态视图控制器中,尝试设置以下内容:

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
    [self.parentViewController didRotateFromInterfaceOrientation:fromInterfaceOrientation];
}

这会将视图旋转到其父视图的消息发送到其父视图,即呈现模态窗口的视图

【讨论】:

    【解决方案2】:

    我在开发的应用程序中遇到了类似的问题。事实证明,我的问题是我没有正确指定我的控件(例如顶部工具栏)如何增长和伸展。

    如果问题不是代码问题,看一下 IB 看看你是否定义了 autogrow 等。

    【讨论】:

      【解决方案3】:

      原来是导航控制器没有设置 parentViewController 属性的问题。喜欢无证的陷阱...

      简单的解决方案是在导航控制器初始化之后:

      [_navigationController setValue:self forKey:@"_parentViewController"];
      

      对 PrimaryFeather 的支持: Modal View Controller Won't Start in Landscape Mode

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-03-13
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2012-10-21
        相关资源
        最近更新 更多