title: Lock the orientation of the app in a specific View Controller in Swift
body: <p>I'm working on an app that requires locking the orientation in each view controller.
  I read <a href="https://stackoverflow.com/questions/43795577/how-to-lock-orientation-for-iphone-for-certain-view-controllers-swift">this article</a>, but it did not work for me.
  In the project settings, I set the device orientation to Portrait, Landscape Left, and Landscape right.</p>
  <p><a href="https://i.stack.imgur.com/J1LB2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/J1LB2.png" alt="enter image description here" /></a></p>
  <p>I have two view controllers, VC1 and VC2, and I want to lock the VC1's orientation vertically only. I want to lock the VC2's orientation, on the other hand, horizontally only.</p>
  <p>Then I added the following code in VC1.</p>
  <pre><code>override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
      return UIInterfaceOrientationMask.portrait //return the value as per the required orientation
      }
  
  override var shouldAutorotate: Bool {
          return false
      }
  </code></pre>
  <p>But, I can still able to rotate the VC1 horizontally...
  Side note: VC1 contains a navigation bar and a tab bar.</p>
  <p>If you know how to solve this issue, please let me know...</p>