Locking device orientation on a view fails when going back in NavBar
I have an app with several VCs embedded in a NavigationController. I need all VCs to be locked in a portrait orientation and only one in both portrait and landscape. I've tried different approaches and this one is working for me: extension UINavigationController { public override func supportedInterfaceOrientations() -> Int { return visibleViewController.supportedInterfaceOrientations() } public override func shouldAutorotate() -> Bool { return visibleViewController.shouldAutorotate() } } And then I modify each ViewController like this: class ViewController: UIViewController { override func