UINavigationController 模式对话框的旋转问题

发布于 2024-11-09 20:31:49 字数 537 浏览 4 评论 0原文

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

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

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

一切都运行良好,直到您:

  1. 打开模式对话框
  2. 旋转到横向(或另一个方向)
  3. 关闭对话框。

此时,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:

  1. Open a modal dialog
  2. Rotate into landscape (or to another orientation)
  3. 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:

Screenshot after rotation

Any idea?
Thanks

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

原谅过去的我 2024-11-16 20:31:52

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

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

[_navigationController setValue:self forKey:@"_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:

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

Props to PrimaryFeather for the idea:
Modal View Controller Won't Start in Landscape Mode

打小就很酷 2024-11-16 20:31:51

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

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

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

In your modal view controller, try setting up the following:

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

This sends the message that the view rotated to its parent, which is the view that presented the modal window

安稳善良 2024-11-16 20:31:51

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

如果问题不是代码问题,请查看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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文