Xcode无法遵守设备方向

时间:2017-02-16 16:33:01

标签: ios objective-c iphone xcode orientation

我已将设备方向设置为仅在Xcode中选中“纵向”。 但是,当我在模拟器中运行我的应用程序时,它会在所有方向上旋转。

My Xcode setting

Showing correctly in Portrait (intended) and Landscape (not intended)

之前有人遇到过同样的问题吗? 感谢

3 个答案:

答案 0 :(得分:8)

"一般" - >"部署信息" Xcode中的UI可能是骗人的。检查info.plist中的这两个键:

UISupportedInterfaceOrientations

UISupportedInterfaceOrientations~ipad

答案 1 :(得分:2)

我遇到了同样的问题(在物理设备中)。在iPhone上它工作正常,但在iPad上它不起作用。解决方案是调整"设备的选项"对于这两种情况,在这种情况下"风景正确"。 Landscape Right checkbox checked under Device Orientation below Deployment Info

答案 2 :(得分:0)

我遇到了同样的问题,花了整整一天的时间,我这样做来解决了: 覆盖AppDelegate方法

    func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
        

        if self.allowOrentitaionRotation {
            return .allButUpsideDown;
        }
        return .portrait;
    }