Search code examples
iosuinavigationcontrollerswiftrotation

shouldAutoRotate not working in swift


I know if VC has navigationController it should contain some like this. But what about swift? How to able call shouldAutoRotate in VC with navigationController? My navigationControllers has standard class UINavigationController (not custom). I want make shouldAutoRotate false for all my VC except single. As I understood there no another ways to just use "Portrait" and make available to rotate single VC


Solution

  • Put this in your view controllers:

    override func shouldAutorotate() -> Bool {
    
         return false // or true for the VC that allows landscape
    }