Home>

~~ `` `Enter your language here Strikethrough

I wrote it as the following page and tried it with simlator, but it was upside down.
https://qiita.com/hikarut/items/c3bea991623a9a26f238
### Error message

No error message

### Applicable source code

swift4   override func viewDidLoad () {         // Support for screen rotation         func supportedInterfaceOrientations ()->UIInterfaceOrientationMask {             // Add allowed screen             let orientation: UIInterfaceOrientationMask = [UIInterfaceOrientationMask.portrait,                                             UIInterfaceOrientationMask.portraitUpsideDown,                                             UIInterfaceOrientationMask.landscapeLeft,                                             UIInterfaceOrientationMask.landscapeRight]             return orientation         }

`` `

Check all "Development info" and "Device orientation"

Supplemental information (language/FW/tool version etc.)

More information

  • Answer # 1

    supportedInterfaceOrientationsmust be correctly positioned.
    This is a method ofUIViewCortroller. To customize it, you need tooverrideit up likeviewDidLoad.

    class ViewController: UIViewController {
      override func supportedInterfaceOrientations ()->UIInterfaceOrientationMask {
        // Add allowed screen
        let orientation: UIInterfaceOrientationMask = [
          UIInterfaceOrientationMask.portrait,
          UIInterfaceOrientationMask.portraitUpsideDown,
          UIInterfaceOrientationMask.landscapeLeft,
          UIInterfaceOrientationMask.landscapeRight]
        return orientation
      }
    }