8
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Swift1.2→Swift2.0に移行した時に出たsupportedInterfaceOrientations()のエラーについて

Last updated at Posted at 2015-10-15

Swift1.2で画面の向きを固定する関数にエラーが!!

Swift
// Swift 1.2
override func supportedInterfaceOrientations() -> Int {
    let orientation = Int(UIInterfaceOrientationMask.Portrait.rawValue | UIInterfaceOrientationMask.PortraitUpsideDown.rawValue)
    return Int(UIInterfaceOrientationMask.All.rawValue)
}

Swift
Error: Method does not override any method from its superclass

これでなんとか

Swift
// Swift 2
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
    let orientation: UIInterfaceOrientationMask = [UIInterfaceOrientationMask.Portrait, UIInterfaceOrientationMask.PortraitUpsideDown]
    return orientation
}
8
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?