iOS - 使用导航控制器旋转
这是一个小但烦人的问题。我正在使用导航控制器,它不会旋转。我之前使用的代码没有导航控制器,并且它旋转得很漂亮。它现在甚至没有调用“-(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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
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 aUIWindow
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.
您的控制器需要返回YES:
此外,如果您有一个UITabBarController,每个控制器都需要该方法返回YES。
Your controller need to have return YES in:
Also if you have an UITabBarController, each controllers need that method to return YES.