Last active
May 23, 2017 12:05
-
-
Save ilandbt/7a43c38e56446fc338778b672749fee8 to your computer and use it in GitHub Desktop.
disabling autorotate
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MainNavigationController: UINavigationController { | |
// autorotate by top viewController | |
override var shouldAutorotate: Bool { | |
if !viewControllers.isEmpty { | |
return self.topViewController!.shouldAutorotate | |
} else { | |
return true | |
} | |
} | |
// orientation by top viewController | |
override var supportedInterfaceOrientations: UIInterfaceOrientationMask{ | |
if !viewControllers.isEmpty { | |
return self.topViewController!.supportedInterfaceOrientations | |
} else { | |
return self.supportedInterfaceOrientations | |
} | |
} | |
} | |
class ViewController: UIViewController { | |
// disable autoratation | |
override var shouldAutorotate : Bool { | |
return false | |
} | |
//only portrait allowed | |
override var supportedInterfaceOrientations : UIInterfaceOrientationMask { | |
return UIInterfaceOrientationMask.portrait | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment