我刚刚将一个项目迁移到Swift 2.0,这个以前工作的代码现在产生了一个错误:
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {  
        return Int(UIInterfaceOrientationMask.PortraitUpsideDown.rawValue) | Int(UIInterfaceOrientationMask.Portrait.rawValue)  
    } 
该错误表明返回类型不正确,但我已经尝试了几种方法来返回它,没有运气.
无法将类型为'Int'的返回表达式转换为返回类型'UIInterfaceOrientationMask'
Dan*_*avo 44
从Swift 2.0开始,使用掩码值数组替换位掩码,现在应该读取代码:
 override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
    return [.Portrait, .PortraitUpsideDown]
}
有一个Swift 3.0的supportedInterfaceOrientations更新:
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {  
    return UIInterfaceOrientationMask.portrait  
}
和自动旋转功能:
override var shouldAutorotate: Bool {
    return true
}
| 归档时间: | 
 | 
| 查看次数: | 6451 次 | 
| 最近记录: |