错误 Swift 方法没有覆盖它的超级 class 中的任何方法
Error Swift Method Does Not Override any Method from it's super class
override func supportedInterfaceOrientations() -> Int {
if UIDevice.currentDevice().userInterfaceIdiom == .Phone {
return Int(UIInterfaceOrientationMask.AllButUpsideDown.rawValue)
} else {
return Int(UIInterfaceOrientationMask.All.rawValue)
}
}
所以我正在编写一个教程,我已经完成了它,当我更新到 xcode 7 时,我的所有代码都充满了错误。
在上面的文章中我收到错误 "method does not override any method from its super class" 但是当我删除覆盖时我收到此错误:方法 'supportedInterfaceOrientations()' 与 Objective-C 选择器 'supportedInterfaceOrientations' 冲突来自超类 'UIViewController' 的方法 'supportedInterfaceOrientations()' 具有相同的 Objective-C 选择器
我一直在研究,但我对编程还很陌生,这里的很多答案我都不太理解,无法应用于我的情况。
谢谢
它不再是 returns 而是 Int
。新方法签名需要返回 UIInterfaceOrientationMask
。
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
if UIDevice.currentDevice().userInterfaceIdiom == .phone {
return UIInterfaceOrientationMask.allButUpsideDown
} else {
return UIInterfaceOrientationMask.all
}
}
override func supportedInterfaceOrientations() -> Int {
if UIDevice.currentDevice().userInterfaceIdiom == .Phone {
return Int(UIInterfaceOrientationMask.AllButUpsideDown.rawValue)
} else {
return Int(UIInterfaceOrientationMask.All.rawValue)
}
}
所以我正在编写一个教程,我已经完成了它,当我更新到 xcode 7 时,我的所有代码都充满了错误。
在上面的文章中我收到错误 "method does not override any method from its super class" 但是当我删除覆盖时我收到此错误:方法 'supportedInterfaceOrientations()' 与 Objective-C 选择器 'supportedInterfaceOrientations' 冲突来自超类 'UIViewController' 的方法 'supportedInterfaceOrientations()' 具有相同的 Objective-C 选择器
我一直在研究,但我对编程还很陌生,这里的很多答案我都不太理解,无法应用于我的情况。
谢谢
它不再是 returns 而是 Int
。新方法签名需要返回 UIInterfaceOrientationMask
。
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
if UIDevice.currentDevice().userInterfaceIdiom == .phone {
return UIInterfaceOrientationMask.allButUpsideDown
} else {
return UIInterfaceOrientationMask.all
}
}