在iPad上的IOS 6中,初始旋转始终是纵向,之后它始终正确旋转 [英] In IOS 6 on iPad, initial rotation is always portrait, after that it always rotates correctly

查看:132
本文介绍了在iPad上的IOS 6中,初始旋转始终是纵向,之后它始终正确旋转的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在iOS 5.X下正常运行且支持所有方向的发货应用程序,针对iOS 6构建,即使在ipad /模拟器处于横向状态时也始终以纵向方式启动。

In a shipping app that has worked correctly under iOS 5.X and supports all orientations, built against iOS 6 it always starts in portrait even when the ipad/simulator is in landscape).

我确实添加了新的旋转方法

I did add the new rotation methods

- (BOOL)shouldAutorotate NS_AVAILABLE_IOS(6_0);
- (NSUInteger)supportedInterfaceOrientations NS_AVAILABLE_IOS(6_0);

但没有区别。

注意我们使用导航控制器作为根视图控制器。否则,应用程序在初始问题后正确旋转。

Note we do not use a navigation controller as the root view controller. Otherwise the app rotates correctly after the initial problem.

根视图控制器处理旋转的所有决策,并作为

The root view controller handles all the decision making for rotations and is added to the main window as

    self.window.rootViewController = viewController;

我在plist键集中有所有旋转UISupportedInterfaceOrientations~ipad

I have all the rotations in the plist key set UISupportedInterfaceOrientations~ipad

为什么忽略初始轮换的任何想法?

Any ideas why the initial rotation is ignored?

在5.1下,它会正确调用shouldAutorotateToInterfaceOrientation和willRotateToInterfaceOrientation等,但不能低于6.0。如果我构建5.1 SDK,那么一切都很好。

Under 5.1 it calls shouldAutorotateToInterfaceOrientation and willRotateToInterfaceOrientation, etc. correctly but not under 6.0. If I build against 5.1 SDK then all is well.

推荐答案

在与Apple交谈后,他们声称这是Xcode 4.5中的一个错误在现有项目上。您可以创建一个新项目并重新添加所有内容(很难与像我们这样的大项目)。或者为你添加如下旋转逻辑:

After talking with Apple, they claim it is a bug in Xcode 4.5 on existing projects. Either you can create a new project and re-add everything (hard to do with a big project like ours). Or add you rotation logic something like this:

- (void)viewWillLayoutSubviews
{
    if ( ! afterFirstTime )
    {
        [self handleRotationFor:self.interfaceOrientation];
        afterFirstTime = YES;
    }
}

- (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    [self handleRotationFor:toInterfaceOrientation];
}

。我在感恩节休息之前得到了这个答案所以它可能有点粗略,但这段代码确实有用。

on your root view controller. I got this answer right before their break Thanksgiving week so it might be a little sketchy, but this code does work.

这篇关于在iPad上的IOS 6中,初始旋转始终是纵向,之后它始终正确旋转的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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