从横向方向从iPhone 6 Plus主屏幕启动纵向导致错误的方向 [英] Launching into portrait-orientation from an iPhone 6 Plus home screen in landscape orientation results in wrong orientation

查看:121
本文介绍了从横向方向从iPhone 6 Plus主屏幕启动纵向导致错误的方向的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题的实际标题比我可能适合的时间长:

The actual title for this question is longer than I can possibly fit:

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

Launching an app whose root view controller only supports portrait-orientation but which otherwise supports landscape orientations on an iPhone 6 Plus while the home screen is in a landscape orientation results in a limbo state where the app's window is in a landscape orientation but the device is in a portrait orientation.

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

In short, it looks like this:

如果它看起来像这样:

重现步骤:


  1. 运行iOS 8.0的iPhone 6 Plus。

  1. iPhone 6 Plus running iOS 8.0.

一个应用程序,其plist支持所有-but-portrait-up-down orientation。

An app whose plist supports all-but-portrait-upside-down orientations.

该应用程序的根视图控制器是一个UITabBarController。

The root view controller of the app is a UITabBarController.

Everyth ing,标签栏控制器及其所有后代子视图控制器从 supportedInterfaceOrientations 返回 UIInterfaceOrientationMaskPortrait

Everything, the tab bar controller and all its descendent child view controllers return UIInterfaceOrientationMaskPortrait from supportedInterfaceOrientations.

从iOS主屏幕开始。

旋转到横向(需要iPhone 6 Plus)。

Rotate to landscape orientation (requires iPhone 6 Plus).

冷启动应用程序。

结果:界面方向损坏。

我想不出任何其他方式来强制执行纵向除了以完全禁用景观,我不能这样做:我们的网页浏览器模态视图控制器需要格局。

I can't think of any other way to enforce a portrait orientation except to disable landscape altogether, which I can't do: our web browser modal view controllers need landscape.

我甚至尝试了子类化UITabBarController并重写supportedInterfaceOrientations来返回仅限肖像的蒙版,但这个(甚至与上述所有其他步骤一起)没有解决问题。

I even tried subclassing UITabBarController and overriding supportedInterfaceOrientations to return the portrait-only mask, but this (even with all the other steps above) did not fix the issue.

这是一个示例项目的链接由于这个错误。

推荐答案

这似乎是个bug在iOS 8中使用UITabBarController作为根视图控制器。解决方法是使用大多数香草UIViewController作为根视图控制器。这个vanilla视图控制器将作为标签栏控制器的父视图控制器:

This appears to be a bug in iOS 8 when using a UITabBarController as a root view controller. A workaround is to use a mostly vanilla UIViewController as the root view controller. This vanilla view controller will serve as the parent view controller of your tab bar controller:

///------------------------
/// 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];

这篇关于从横向方向从iPhone 6 Plus主屏幕启动纵向导致错误的方向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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