Skip to content

Instantly share code, notes, and snippets.

@krodak
Created February 8, 2016 18:03
Show Gist options
  • Save krodak/26ecbb59d2ae39cbe1ee to your computer and use it in GitHub Desktop.
Save krodak/26ecbb59d2ae39cbe1ee to your computer and use it in GitHub Desktop.
extension UIViewController {
func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
if let nvc = self as? UINavigationController {
return nvc.topViewController!.supportedInterfaceOrientations()
} else {
return .Portrait
}
}
func shouldAutorotate() -> Bool {
if let nvc = self as? UINavigationController {
return nvc.topViewController!.shouldAutorotate()
} else {
return false
}
}
func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
if let nvc = self as? UINavigationController {
return nvc.topViewController!.preferredInterfaceOrientationForPresentation()
} else {
return .Portrait
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment