ViewController 外接显示器方向

ViewController orientation on external monitor

我有一个 iPad 自助服务终端应用程序,可以在通过 HDMI 电缆连接的外部显示器上显示视频。设备方向在应用程序的常规设置中设置为横向左或横向右。我希望应用程序在 iPad 和外接显示器上横向显示。当我 运行 iOS7 中的应用程序时,外部监视器视图控制器在横向方向上正确显示,但是当 运行 在 iOS 8 下时,外部监视器的视图控制器旋转了 90 度逆时针方向,纵向。

如何将外接显示器强制设置为正确的横向? iOS 7 和 8 之间发生了什么变化导致了这种行为?

我在支持 airplay 的横向 iPad 应用程序中遇到了类似的问题。在 iPad 屏幕上,一切正常,但在外部显示器上,从@ iOS 8.0 开始,方向问题开始出现。我尝试了很多东西,最终有帮助的是这两个修复:

关于你的 shouldAutorotate 方法 ViewController, return NO.

实施application:supportedInterfaceOrientationsForWindow:方法:

    - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)_window
    {
        if ([UIScreen mainScreen] == _window.screen || !_window)
        {
            return UIInterfaceOrientationMaskAll;
        }
        else
        {
            return UIInterfaceOrientationMaskPortrait;
        }
    }

修复的第二部分可能需要您进行一些更改,因为您没有使用 AirPlay,但我希望它可以帮助您找到正确的解决方案。祝你好运!