相关疑难解决方法(0)

iOS 11设备方向自动旋转

对于iOS 10及更低版本,以下代码控制任何相应的方向UIViewController.我选择了Portrait,Landscape LeftLandscape Right我的部署信息,并在我下面的Info.plist:

在此输入图像描述

对于那些根本应该旋转的VC,我有以下代码,我说过,它在iOS 11之前工作

- (BOOL)shouldAutorotate {
    [super shouldAutorotate];
    return NO;
}

- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    [super supportedInterfaceOrientations];
    return UIInterfaceOrientationMaskPortrait;
}
Run Code Online (Sandbox Code Playgroud)

我已经在实际设备上测试了这个,而且从iOS 11开始它不起作用.

更奇怪的是,从iOS 11开始记录已注册的设备方向告诉我设备纵向...当控制器以横向模式加载时......

码:

// In viewDidLoad 
NSLog(@"orientation: %lu", [[UIDevice currentDevice] orientation]);
Run Code Online (Sandbox Code Playgroud)

控制台输出:

2017-09-22 15:20:26.225196-0400 <APP_NAME>[2669:1628408] orientation: 1
Run Code Online (Sandbox Code Playgroud)

这可能是在构建和运行应用程序之前向左或向右旋转设备.


  • 这个错误的原因是什么?如果有人知道请帮助..

仅供参考:不,我的设备上没有旋转锁定..

objective-c orientation ios swift ios11

8
推荐指数
1
解决办法
4570
查看次数

iOS 10 和 swift 2.3 中的 supportedInterfaceOrientations

我正在使用 Xcode 8 GM 并且有一个需要针对 iOS 10 更新的旧项目。

我发现我当前使用 Swift 2.2 版构建的应用商店在 iOS 10 上运行时不支持所需的界面定向功能

简单地说,当我覆盖 supportedInterfaceOrientations() 时,它在 iOS 10 上运行时永远不会被调用。

在以前的版本上它工作正常。

我可以看到签名已更改,因此 supportedInterfaceOrientations 现在是 var 而不是方法,但这似乎只适用于 Swift 3 而不适用于 Swift 2.3。当我尝试在 Swift 2.3 中作为 var 覆盖时,它不会编译,如果我使用旧签名,它在 iOS 10 下永远不会被调用

有任何想法吗?

swift ios10

5
推荐指数
1
解决办法
9551
查看次数

标签 统计

swift ×2

ios ×1

ios10 ×1

ios11 ×1

objective-c ×1

orientation ×1