2015-11-18 36 views
1
override func supportedInterfaceOrientations() -> Int { 
    if UIDevice.currentDevice().userInterfaceIdiom == .Phone { 
     return Int(UIInterfaceOrientationMask.AllButUpsideDown.rawValue) 
    } else { 
     return Int(UIInterfaceOrientationMask.All.rawValue) 
    } 
} 

所以我工作的一個教程,我已經完成了它,當我更新到xcode的7我的代碼得到了與錯誤散落。我得到這個錯誤:方法'supportedInterfaceOrientations()'與Objective-C選擇器'supportedInterfaceOrientations'方法'supportedInterfaceOrientations()'在上面的部分我得到錯誤「方法不重寫任何方法從它的超類」與使用相同的Objective-C選擇器的超類'UIViewController'的方法'supportedInterfaceOrientations()'衝突錯誤斯威夫特方法不覆蓋任何方法從它的超類

我一直在研究,但我對編程頗爲陌生,很多答案在這裏我不明白足以適用於我的情況。

謝謝

回答

3

它不再返回Int。新方法簽名需要返回UIInterfaceOrientationMask

override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask { 
    if UIDevice.currentDevice().userInterfaceIdiom == .phone { 
     return UIInterfaceOrientationMask.allButUpsideDown 
    } else { 
     return UIInterfaceOrientationMask.all 
    } 
} 
+0

感謝您的幫助! – Domo

相關問題