如何让 UINavigationController 旋转,而不是子视图?

发布于 2024-12-01 09:56:35 字数 388 浏览 0 评论 0原文

我下载了“Autodesk”的免费 iPad 应用程序“SketchBook Express”。 其中,它们有一个绘图表面和(我认为是)一个 UINavigationController。我感兴趣的是,导航控制器栏随 iPad 一起旋转,但绘图的内容却没有。因此,如果我将 iPad 从纵向调整为横向,导航栏就会移动到新的顶部,但我绘制的草图现在位于其一侧。我想为我的程序实现类似的东西,但我一直无法做到。

我玩过 shouldAutorotateToInterfaceOrientation: 但到目前为止我才发现它只被调用一次。我创建了 UINavigationController 的子类并让它返回 YES,并让我的子视图控制器返回 NO。但这并没有达到目的。

有没有一种简单的方法可以做到这一点?

I downloaded the free iPad application "SketchBook Express" by "Autodesk".
In it, they have a drawing surface, and (what I believe is) a UINavigationController. What interests me is that the navigation controller bar rotates with the iPad, but the content of the drawing does not. So if I put the iPad from portrait to landscape, the nav bar moves to the new top, but the sketch I've drawn is now on its side. I would like to implement something similar for my program, but I have been unable to.

I've played with shouldAutorotateToInterfaceOrientation: but so far I've just figured out it is only called once. I made a subclass of UINavigationController and had that return YES, and had my subview controller return NO. That did not do the trick.

Is there a simple way to do this?

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

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

发布评论

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

评论(1

赴月观长安 2024-12-08 09:56:35

旋转的内容可能包含在 UIViewController(或 UINavigationController)的视图中。
其他东西(不旋转)可能包含在任何 UIViewController 不包含的视图中(或者在 shouldAutorotateToInterfaceOrientation 方法中返回 NO 的控制器)。

这意味着您可以尝试将绘图视图设置为 keyWindow 的子视图。
其他东西可以像往常一样在视图控制器中。

是不是我没有尝试过,这只是一个想法。我很想知道这是否有效。 :)

What rotates is probably contained by a UIViewController (or UINavigationController)'s view.
Other things (that don't rotate) are probably contained by a view that is not contained by any UIViewController (or a controller that returns NO in shouldAutorotateToInterfaceOrientation method).

This means that you could try setting your drawing view as a subview of the keyWindow.
Other things could be in the view controller as usual.

Is not I have tried, this is just an idea. And I would be interested in knowing if this worked. :)

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