iPad 标签栏应用程序不自动旋转
我制作了一个选项卡栏应用程序,但它不会旋转为横向。
我将“shouldAutoRotate”设置为“return YES”,但这不起作用......有什么建议吗?
I made a tab bar application, but it will not rotate into landscape.
I have the 'shouldAutoRotate' set to "return YES" but that doesn't work... Any suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
标签栏控制器中的所有视图控制器都需要为横向返回 YES 才能旋转。
All of the view controllers in the tab bar controller need to return YES for landscape in order for it to rotate.
我也这么认为,因为当应用程序启动时,所有视图控制器的“shouldAutoRotate”都会被解雇。
I also think so because when app launches all the view controller's 'shouldAutoRotate' getting fired..
我的应用程序中发生了什么,我使用的是现成的 UITabBarController,我将其拖到 xCode 界面生成器中。它不会自行旋转(我想默认情况下它只是显示纵向)。
解决方案是创建一个新类(右键单击文件列表)New File >目标C级>然后在“子类:”中输入 UITabBarController,并给它一个有意义的名称(例如 MyUITabBarControllerInHorisontalOrientation),
您创建了一个具有 UITabBarController 所有功能的文件,但您还可以向其中添加更多功能。因此,您需要在 .m 文件中添加如下功能:
然后在界面构建器(拖放按钮的所见即所得界面)中单击您拖过的 UITabBarController 并在 Utilities > 中添加身份检查员>自定义类(通常作为右侧面板可见)选择了您的 MyUITabBarControllerInHorisontalOrientation。
我希望它有帮助
What happened in my app I was using off the shelf UITabBarController which I dragged over in xCode interface builder. It did not rotate itself (I guess by defauls it just displays portrait).
Solution was to create a new class (with right click on the file list) New File > Objective C Class > and then in "Subclass of:" type UITabBarController, and give it a meaningful name (like MyUITabBarControllerInHorisontalOrientation)
What happened you created a file which has all the functions of UITabBarController, but also you can add few more to it. So you need to add in .m file a function like this:
and then in interface builder (the wysiwyg interface where you drag and drop buttons) click your UITabBarController you dragged over and in Utilities > Identity Inspector > Custom class (often visible as a right hand side panel) chose your MyUITabBarControllerInHorisontalOrientation.
I hope it helps