当我开始覆盖视图控制器时,为什么 iPad 会停止自动旋转?

发布于 2024-09-12 16:21:43 字数 542 浏览 2 评论 0原文

我有一个相当庞大的项目,我正在其中一个接一个地加载一些视图控制器。首先是启动屏幕,然后是菜单系统,当用户单击菜单时,它会进入文章视图控制器。

将所有这些放入 shouldAutorotate... 将所有旋转设置为 YES,效果很好。但是,我有一个菜单栏,当识别到点击手势时,我需要从顶部向下滑动。我有一个用于主菜单,一个用于文章视图。

如果我把其中之一放进去,它仍然可以很好地自动旋转。然而,一旦我放入下一个,自动旋转就停止工作。我尝试将菜单栏放入应用程序委托中,并将它们嵌套在菜单/文章视图控制器中。菜单栏视图控制器还将 shouldAutorotate... 设置为 YES。事实上,项目中的每个视图控制器(全部 7 个)都将其设置为 YES。然而,当我添加第二个菜单栏控制器时,它停止自动旋转。它甚至不会触发“shouldAutorotate”方法来询问它。

该代码太大,无法在此发布,但如果您想查看任何特定内容,请询问。我完全被难住了!我即将将菜单栏从视图控制器中拉出,并在每个视图控制器中单独对它们进行编码。这将是大量的代码重复,但我想不出任何其他方法!

有什么想法吗?谢谢!

I have a fairly hefty project, where I am loading a few view controllers, one after the other. First, a splash screen, followed by a menu system, and when the user clicks on the menu it goes through to an article view controller.

Putting all these in with shouldAutorotate... set to YES for all rotations, this works fine. However, I have a menu bar I need to slide down over the top when a tap gesture has been recognised. I have one for the main menu, and one for the article view.

If I put one of these in, it still auto-rotates fine. However, as soon as I put the next one in, the auto-rotate stops working. I've tried putting the menu bars in the app delegate, as well as nesting them inside the menu/article view controllers. The Menu Bar view controller also has shouldAutorotate... set to YES. In fact, every single view controller in the project (all 7 of them) have it set to YES. And yet, when I add my second Menu bar controller, it stops auto-rotating. It doesn't even trigger the "shouldAutorotate" method to ask it.

The code is way too large to post here, but if you'd like to see anything in particular then just ask. I'm totally stumped! I'm about to pull the menu bars out of their view controller and code them up in each of the view controllers individually. This will be a hideous amount of code duplication, but I can't think of any other way round it!

Any ideas? Thanks!

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

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

发布评论

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

评论(1

落花浅忆 2024-09-19 16:21:43

答案似乎是......不要将视图控制器放在其他视图控制器中!一个视图控制器 = 一个屏幕,似乎是规则。我还有很多东西要学!

The answer appears to be... Don't put view controllers within other view controllers! One view controller = one screen, seems to be the rule. I have a lot to learn!

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