override func supportedInterfaceOrientations() -> Int {
if UIDevice.currentDevice().userInterfaceIdiom == .Phone {
return Int(UIInterfaceOrientationMask.AllButUpsideDown.rawValue)
} else {
return Int(UIInterfaceOrientationMask.All.rawValue)
}
}
所以我正在编写教程并完成了它,当我更新到 xcode 7 时,我的所有代码都充满了错误。
在上面的文章中,我收到错误“方法没有覆盖其父类(super class)中的任何方法”,但是当我删除覆盖时,我收到此错误:方法“supportedInterfaceOrientations()”与 Objective-C 选择器“supportedInterfaceOrientations”冲突使用来自具有相同 Objective-C 选择器的父类(super class)“UIViewController”的方法“supportedInterfaceOrientations()”
我一直在研究,但我对编程很陌生,这里的很多答案我都不太理解,无法应用于我的情况。
谢谢
最佳答案
它不再返回 Int
。新方法签名需要返回一个 UIInterfaceOrientationMask
。
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
if UIDevice.currentDevice().userInterfaceIdiom == .phone {
return UIInterfaceOrientationMask.allButUpsideDown
} else {
return UIInterfaceOrientationMask.all
}
}
关于ios - 错误 Swift 方法不会覆盖其父类(super class)中的任何方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33788038/