iOS - 使用导航控制器旋转

发布于 2024-10-18 02:03:04 字数 315 浏览 2 评论 0原文

这是一个小但烦人的问题。我正在使用导航控制器,它不会旋转。我之前使用的代码没有导航控制器,并且它旋转得很漂亮。它现在甚至没有调用“-(BOOL)shouldAutororateToInterfaceOrientation...”,所以我有点不知所措。

提前致谢。

编辑:是的,我设置了“-(BOOL)canBecomeFirstResponder”。

Edit2:现在,当应用程序首次运行时,我让它调用“-(BOOL)shouldAutororateToInterfaceOrientation...”,此时屏幕旋转,但当它显示导航控制器时,将其设置回纵向模式...

It's a small but annoying issue. I'm using a navigation controller and it will not rotate. I was using the code before without a navigation controller and it was rotating beautifully. It isn't even calling "-(BOOL)shouldAutororateToInterfaceOrientation..." now so I'm at a bit of a loss.

Thanks in advance.

Edit: And yes I have "-(BOOL)canBecomeFirstResponder" set.

Edit2: I have it calling "-(BOOL)shouldAutororateToInterfaceOrientation..." now when the App first runs and at this point the screen is rotated but then when it shows the Navcontroller sets it back to portrait mode...

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

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

发布评论

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

评论(2

茶花眉 2024-10-25 02:03:04

UIWindow 将这些事件传播到根控制器以外的视图控制器时存在问题。如果您要将此控制器直接添加到 UIWindow 中,并且它不是您添加的第一个控制器,则请将其添加到根视图中。

否则,您可能需要考虑实现自己的旋转转换。我有一个 UIViewController 子类,在 github 上为您完成繁重的工作。

There's a problem with UIWindow propagating these events to view controllers other than the root one. If you're adding this controller directly to a UIWindow and it isn't the first one you've added, then add it to the root view instead.

Otherwise, you'll probably need to take a look at implementing your own rotation transformations. I've got a UIViewController subclass which does the heavy lifting for you on github here.

深巷少女 2024-10-25 02:03:04

您的控制器需要返回YES

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  // Overriden to allow any orientation.
  return YES;
}

此外,如果您有一个UITabBarController,每个控制器都需要该方法返回YES。

Your controller need to have return YES in:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
  // Overriden to allow any orientation.
  return YES;
}

Also if you have an UITabBarController, each controllers need that method to return YES.

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