UiSplitViewController 不会自动旋转 [英] UiSplitViewController doesn't autorotate

查看:27
本文介绍了UiSplitViewController 不会自动旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近遇到了一个问题.我的 iPad 应用程序以某种方式阻止 iPad 自动旋转.我的应用程序加载一个 UISplitView,两个视图控制器都为 shouldAutorotateToInterfaceOrientation: 返回 YES.我已将 info.plist 设置为包含所有四个方向的支持的界面方向"键.但是,当我运行应用程序时,旋转设备并不会旋转 splitView(即使我收到 UIDeviceOrientationDidChangeNotification).此外,当我以不同的方向退出我的应用程序时,它在 iPad 主屏幕中启动时不会自动旋转到正确的视图,直到我再次旋转它而不运行我的应用程序......任何想法将不胜感激.......

I have recently run into a problem. My iPad app is somehow preventing the iPad from auto-rotating. My app loads a UISplitView with both of the view controllers returning YES for shouldAutorotateToInterfaceOrientation:. I have set up my info.plist to include the "Supported interface orientations" key with all four orientations. When I run the app, however, rotating the device does not rotate the splitView (even though I am receiving UIDeviceOrientationDidChangeNotification). In addition, when I exit my app in a different orientation that it started in the iPad home screen doesn't autorotate to the correct view until I rotate it again without my app running.... Any Ideas would be much appreciated....

推荐答案

UISplitViewController 是我曾经使用过的最具气质的视图控制器子类之一.为了使其完美"工作,它必须作为应用程序窗口中的单个根视图存在.然而,你可以通过一些技巧来解决这个问题——在我的例子中,我需要一个 UITabBarController 至少有两个不同的 UISplitViewController 作为视图控制器——但是你必须处理涉及旋转和 UISplitViewControllerDelegate 回调未触发的奇怪情况.

UISplitViewController is one of the most temperamental view controller subclasses I've ever had to use. In order for it to work "perfectly", it must exist as a single root view in your application's window. You can, however, get around this with some trickery -- in my case, I needed a UITabBarController with at least two distinct UISplitViewControllers as view controllers -- but then you have to take care of weird cases involving rotation and UISplitViewControllerDelegate callbacks not firing.

希望苹果在未来让 UISplitViewController 与其他 UIKit 组件更加兼容......

Here's hoping that Apple makes UISplitViewController more compatible with other UIKit components in the future...

这篇关于UiSplitViewController 不会自动旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆