首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >从iPhone 6 Plus主屏幕以横向启动进入纵向会导致方向错误

从iPhone 6 Plus主屏幕以横向启动进入纵向会导致方向错误
EN

Stack Overflow用户
提问于 2014-09-24 03:22:16
回答 13查看 26.4K关注 0票数 58

这个问题的实际标题太长了,我无法适应:

启动一个应用程序,其根视图控制器仅支持纵向,但在主屏幕处于横向时支持iPhone 6Plus上的横向,会导致应用程序的窗口处于横向但设备处于纵向的边缘状态。

简而言之,它看起来像这样:

当它看起来像这样的时候:

再现的步骤:

运行orientations.

  • The 8.0的

  • iPhone 6 Plus。如果应用程序的plist支持除纵向颠倒外的所有应用程序,则该应用程序的根视图控制器是iOS标签栏控制器及其所有后代子视图控制器都会从主screen.

  • Rotate的supportedInterfaceOrientations.

  • Start返回横向(需要

6 Plus).

  • Cold-launch iOS应用程序。

  • 结果: broken UIInterfaceOrientationMaskPortrait orientations.

除了完全禁用横向之外,我想不出任何其他方法来强制使用纵向,但我不能这样做:我们的web浏览器模式视图控制器需要横向。

我甚至尝试对UITabBarController进行子类化并覆盖supportedInterfaceOrientations以返回仅用于肖像的掩码,但这(即使使用上面的所有其他步骤)也不能解决问题。

Here's a link to a sample project showing the bug.

EN

回答 13

Stack Overflow用户

回答已采纳

发布于 2014-09-24 03:22:16

当使用UITabBarController作为根视图控制器时,这似乎是iOS 8中的一个错误。一种解决方法是使用一个普通的UIViewController作为根视图控制器。这个普通的视图控制器将作为标签栏控制器的父视图控制器:

代码语言:javascript
复制
///------------------------
/// Portrait-Only Container
///------------------------

@interface PortraitOnlyContainerViewController : UIViewController

@end

@implementation PortraitOnlyContainerViewController

- (NSUInteger)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskPortrait;
}

@end

// Elsewhere, in app did finish launching ...

PortraitOnlyContainerViewController *container = nil;

container = [[PortraitOnlyContainerViewController alloc] 
              initWithNibName:nil 
              bundle:nil];

[container addChildViewController:self.tabBarController];
self.tabBarController.view.frame = container.view.bounds;
[container.view addSubview:self.tabBarController.view];
[self.tabBarController didMoveToParentViewController:container];

[self.window setRootViewController:container];
票数 6
EN

Stack Overflow用户

发布于 2014-10-28 06:41:26

当我在iPhone 6Plus上启动我们的应用程序时,也遇到了同样的问题。

我们的修复方法是通过项目设置从plist中删除横向支持的界面方向:

并在app委托中实现application:supportedInterfaceOrientationsForWindow::

代码语言:javascript
复制
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {
    return UIInterfaceOrientationMaskAllButUpsideDown;
}

显然,plist中的信息是指定您的应用程序可以启动的方向。

票数 79
EN

Stack Overflow用户

发布于 2014-10-01 12:06:27

设置UIApplicationstatusBarOrientation似乎对我很有效。我把它放在app委托的application:didFinishLaunchingWithOptions:方法中。

代码语言:javascript
复制
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    application.statusBarOrientation = UIInterfaceOrientationPortrait;

    // the rest of the method
}
票数 38
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/26003086

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档