这个问题的实际标题比我能容纳的要长:
在 iPhone 6 Plus 上启动其 Root View Controller 仅支持纵向但在其他方面支持横向的应用程序,而主屏幕处于横向方向会导致应用程序的窗口处于横向方向但设备处于纵向。
简而言之,它看起来像这样:
当它应该看起来像这样时:
重现步骤:
运行 iOS 8.0 的 iPhone 6 Plus。
一个应用程序,其 plist 支持除纵向倒置之外的所有方向。
应用的 Root View Controller 是 UITabBarController。
一切,选项卡栏 Controller 及其所有 subview Controller 都从
supportedInterfaceOrientations
返回UIInterfaceOrientationMaskPortrait
。从 iOS 主屏幕开始。
旋转到横向(需要 iPhone 6 Plus)。
冷启动应用。
结果:界面方向损坏。
我想不出任何其他方法来强制纵向方向除了完全禁用横向,我做不到:我们的网络浏览器模态视图 Controller 需要横向。
我什至尝试子类化 UITabBarController 并覆盖 supportedInterfaceOrientations 以返回仅纵向 mask ,但这(即使执行了上述所有其他步骤)也没有解决问题。
Here's a link to a sample project showing the bug.
最佳答案
我在 iPhone 6 Plus 上横向启动我们的应用程序时遇到了同样的问题。
我们的解决方法是通过项目设置从 plist 中删除横向支持的界面方向:
并在应用委托(delegate)中实现 application:supportedInterfaceOrientationsForWindow:
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
return UIInterfaceOrientationMaskAllButUpsideDown;
}
显然,您的 plist 中的信息用于指定允许您的应用启动的方向。
关于ios - 从横向方向的 iPhone 6 Plus 主屏幕进入纵向方向会导致方向错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26003086/