I need the entire app to be locked in PortraitView, except for one view Controller. I need the functionality of these functions but I get an error for having both. When I add the view controller functions app crashes. If i take away the app delegate the view controller does what I need it too.
App Delegate
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return UIInterfaceOrientationMask(rawValue: UIInterfaceOrientationMask.portrait.rawValue)
}
ViewController
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return .landscapeRight
}
override var shouldAutorotate: Bool {
return true
}
Edited to use Base Controller View:
As I can recall if the orientation is enabled for the app. The orientation functions needs to be implemented for every controller that needs to restrict it.
Alternatively, create Base UIViewController that supports Portrait
. which should be inherited by all controllers and only override the orientation functions in the landscape controller.
Something like the following:
class BaseViewController : UIViewController {
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return .Portrait...
}
}
class ViewController1: BaseViewController {
// nothin to override
}
class LandscapeController: BaseViewController {
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return .landscapeRight
}
}