在 iOS 5.X 下正常工作并支持所有方向的运输应用程序中,针对 iOS 6 构建的它始终以纵向启动,即使 ipad/模拟器处于横向状态也是如此。
我确实添加了新的旋转方法
- (BOOL)shouldAutorotate NS_AVAILABLE_IOS(6_0);
- (NSUInteger)supportedInterfaceOrientations NS_AVAILABLE_IOS(6_0);
但这没有什么区别。
请注意我们这样做not使用导航控制器作为根视图控制器。否则,应用程序会在出现初始问题后正确旋转。
根视图控制器处理所有旋转决策并添加到主窗口中
self.window.rootViewController = viewController;
我在 plist 键集中设置了所有旋转 UISupportedInterfaceOrientations~ipad
任何想法为什么初始旋转被忽略?
在5.1下它可以正确调用shouldAutorotateToInterfaceOrientation和willRotateToInterfaceOrientation等,但在6.0下则不行。如果我针对 5.1 SDK 进行构建,那么一切都很好。
在与 Apple 交谈后,他们声称这是现有项目上 Xcode 4.5 中的一个错误。您可以创建一个新项目并重新添加所有内容(对于像我们这样的大项目很难做到)。或者添加旋转逻辑,如下所示:
- (void)viewWillLayoutSubviews
{
if ( ! afterFirstTime )
{
[self handleRotationFor:self.interfaceOrientation];
afterFirstTime = YES;
}
}
- (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
[self handleRotationFor:toInterfaceOrientation];
}
在你的根视图控制器上。我在感恩节休息前得到了这个答案,所以可能有点粗略,但这段代码确实有效。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)