0

When I use UITabbarController, I'd like to display only the portrait screen without rotating the screen.

When I am not using UITabBarController, I do not rotate the screen and it is in landscape view.

Therefore, I set the following for ViewController not using UITabBarController.

override var shouldAutorotate: Bool {
    get {
        return true
    }
}
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
    get {
        return .landscapeRight
    }
}

In the specifications of the application, we make the following settings.

enter image description here

I am using UITabbarController in storyboard 1. enter image description here

I am not using UITabbarController in storyboard 2. enter image description here

I'd like to create an application to move from storyboard 1 to storyboard 2.

I do not know how to display the screen vertically only on the ViewController that I use UITabBarController.

jack_three
  • 13
  • 5

1 Answers1

0

i suggest you to create an extension

extension UITabBarController {
  override open var supportedInterfaceOrientations: UIInterfaceOrientationMask {
      return .portrait
  }
}

usage :

 let tabbar = UITabBarController.init()
  _ = tabbar.supportedInterfaceOrientations

or

tabbar.supportedInterfaceOrientations = .portrait
Mohammad Reza Koohkan
  • 1,656
  • 1
  • 16
  • 36
  • I was able to set the vertical screen. However, I had a new problem. I would like to create another question because the explanation of the problem will be long. Thank you for your advice. – jack_three Jul 23 '18 at 10:13