简体   繁体   English

iOS >>设备方向>>屏幕不支持颠倒

[英]iOS >> Device Orientation >> Screen is Not Supporting Upside Down

I have a screen that supports Device Orientation. 我有一个支持设备方向的屏幕。

Everything is working fine except for the fact that when I rotate the device upside down (home button at top), the rotation doesn't work (it's stuck on the last landscape settings). 一切都工作得很好,除了当我将设备上下颠倒(顶部的主页按钮)时,旋转不起作用(它停留在最后的风景设置上)。

I know of several places needed be updated to support this: 我知道有几个地方需要更新以支持这个:

  • In the VC itself, I added the methods: 在VC本身,我添加了方法:

在此输入图像描述

  • In the Project Target, I updated as follow: 在项目目标中,我更新如下:

在此输入图像描述

  • In the Storyboard VC Scene, I updated as follow: 在Storyboard VC Scene中,我更新如下:

在此输入图像描述

What am I missing here? 我在这里错过了什么?

You also have to allow rotating to all orientations in every parent view controller of the current main view controller. 您还必须允许旋转到当前主视图控制器的每个父视图控制器中的所有方向。 For example, if your view controller is in navigation controller, try subclassing it and override the same methods as in your example. 例如,如果您的视图控制器位于导航控制器中,请尝试对其进行子类化并覆盖与示例中相同的方法。

Edit: As @JordanC mentioned, since iOS 7 you can implement UINavigationControllerDelegate method to return custom supported orientations: 编辑:正如@JordanC所提到的,从iOS 7开始,您可以实现UINavigationControllerDelegate方法来返回自定义支持的方向:

- (UIInterfaceOrientationMask)navigationControllerSupportedInterfaceOrientations:(UINavigationController *)navigationController

正如@eGanges所提到的,关键点可能是你的UITabBarController子类化(并覆盖supportedInterfaceOrientations ),如果这是你的初始视图控制器,那么这是你应该子类化的唯一控制器(当然你应该添加所有支持的接口方向到你的应用Info.plist文件UISupportedInterfaceOrientations键)

Have you tested on real device? 你在真实设备上测试过吗?

anyway try this: 无论如何试试这个:

- (NSUInteger)supportedInterfaceOrientations {
    return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM