For those who do not use the UINavigationController , and their default view controller is the UIViewController , you can check which view controller is active (or represented) in AppDelegate :
func application(application: UIApplication, supportedInterfaceOrientationsForWindow window: UIWindow?) -> Int { if let rootViewController = self.window!.rootViewController { if let presentedViewController = rootViewController.presentedViewController { return presentedViewController.supportedInterfaceOrientations() } }
As you can see, I am checking the current view controller to support different interface orientations for specific controllers. For anyone interested in using this method to support specific ones, each view controller that needs a certain orientation should have the following:
override func supportedInterfaceOrientations() -> Int { return Int(UIInterfaceOrientationMask.All.rawValue) }
Note: This code was written using Swift 1.2.
Clay Ellis Apr 30 '15 at 19:46 2015-04-30 19:46
source share