Skip to content

Instantly share code, notes, and snippets.

@gcbrueckmann
Created December 9, 2015 08:36
Show Gist options
  • Save gcbrueckmann/dfb8b60fa7223b9cd706 to your computer and use it in GitHub Desktop.
Save gcbrueckmann/dfb8b60fa7223b9cd706 to your computer and use it in GitHub Desktop.
UINavigationController by default doesn't forward user interface orientation callbacks to its child view controllers. This is a workaround.
import UIKit
final class MindfulNavigationController: UINavigationController {
/// Forward user interface orientation callbacks to top view controller.
var respectsTopViewControllerOrientationConfiguration = true
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
guard respectsTopViewControllerOrientationConfiguration,
let topViewController = topViewController else
{
return super.supportedInterfaceOrientations()
}
return topViewController.supportedInterfaceOrientations()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment