iOS 10和Swift 2.3中的supportInterfaceOrientations [英] supportedInterfaceOrientations in iOS 10 and swift 2.3

查看:51
本文介绍了iOS 10和Swift 2.3中的supportInterfaceOrientations的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Xcode 8 GM,并且有一个旧项目需要为iOS 10更新.

I am using Xcode 8 GM and have an old project that need updating for iOS 10.

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

I have found that my current appstore build using version 2.2 of Swift is not supporting the desired interfaceorientation functionality when running on iOS 10

当我覆盖supportedInterfaceOrientations()时,简而言之,它在iOS 10上运行时永远不会被调用.

Simply put when I override supportedInterfaceOrientations() it never gets called when running on iOS 10.

在以前的版本中,它工作正常.

On previous versions it works fine.

我可以看到签名已经更改,因此supportedInterfaceOrientations现在是一个变量,而不是方法,但这似乎仅适用于Swift 3,而不适用于Swift 2.3.当我尝试在Swift 2.3中重写为var时,它将无法编译,并且如果使用旧签名,它将永远不会在iOS 10下被调用

I can see that the signature has changed so that supportedInterfaceOrientations is now a var and not a method but this only seem to apply to Swift 3 and not to Swift 2.3. When I try to override as a var in Swift 2.3 it will not compile and if I use the old signature it never gets called under iOS 10

有什么想法吗?

推荐答案

对于ios 10,Swift 3.0

For ios 10, Swift 3.0

override var supportedInterfaceOrientations:UIInterfaceOrientationMask {
        return UIInterfaceOrientationMask.all
    }

这篇关于iOS 10和Swift 2.3中的supportInterfaceOrientations的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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