ipad应用程序不会在IOS6中旋转

时间:2013-05-14 00:04:37

标签: ios ipad

我有一个UISplitViewController ipad应用程序。它使用mainwindow.xib和我的子类RootView和DetailView控制器。它可以在高达5.1的所有状态下自动旋转。

我知道ios6的界面发生了变化。当我将新的旋转方法添加到我的细节和rootview类时,它仍然不会旋转。

调用了我的supportedInterfaceOrientations方法,但是永远不应该调用.Autorotate。

有谁知道如何解决这个问题?

(总是知道没有人会像其他程序员那样把你搞得一团糟。感谢Apple。) 格里

2 个答案:

答案 0 :(得分:1)

来自iOS 6 release notes

  

iOS 6中的自动旋转正在发生变化。在iOS 6中,不推荐shouldAutorotateToInterfaceOrientation: UIViewController方法。取而代之的是,您应该使用supportedInterfaceOrientationsForWindow:shouldAutorotate方法。

     

更多责任转移到应用和应用代表。现在,iOS容器(例如UINavigationController)不会咨询他们的孩子以确定他们是否应该自动旋转。默认情况下,应用程序和视图控制器支持的界面方向对于iPad惯用语设置为UIInterfaceOrientationMaskAll,对于iPhone惯用语设置为UIInterfaceOrientationMaskAllButUpsideDown

     

视图控制器支持的界面方向可能会随着时间的推移而变化 - 即使应用程序支持的界面方向也会随着时间的推移而变化。无论何时设备旋转或每当视图控制器呈现全屏模态呈现样式时,系统都要求最顶层的全屏视图控制器(通常是根视图控制器)获得其支持的界面方向。此外,仅当此视图控制器从其shouldAutorotate方法返回YES时,才会检索支持的方向。系统将视图控制器支持的方向与应用程序支持的方向(由Info.plist文件或应用程序代理的application:supportedInterfaceOrientationsForWindow:方法确定)相交,以确定是否旋转。

     

系统通过将应用程序的supportedInterfaceOrientationsForWindow:方法返回的值与最顶层全屏控制器的supportedInterfaceOrientations方法返回的值相交来确定是否支持方向。

     

{@ 1}}方法不会被弃用。它现在只有在最顶层的全屏视图控制器的setStatusBarOrientation:animated:方法返回0时才有效。这使得调用者负责确保状态栏方向一致。

我知道这很满意,但您可能还想检查项目设置中支持的界面方向表:

enter image description here

答案 1 :(得分:0)

尝试在方向更改时设置通知。

[[NSNotificationCenter defaultCenter] addObserver:self
                                         selector:@selector(orientationChanged:)
                                            name:UIDeviceOrientationDidChangeNotification
                                           object:nil];

然后在orientationChanged函数内实现旋转。

- (void)orientationChanged:(NSNotification *)notification {}