Reputation: 476
How can I force change orientation, when viewWillAppear?
I want only one navigationController to force landscape, other controllers I want to portrait.
When I push to landscape controller it shows like portrait, but when I rotate mobile, it locks, like landscape like I want.
How can I do that, when vieWillAppear? Is there any function to that?
Upvotes: 0
Views: 293
Reputation: 408
override func viewDidLoad() {
super.viewDidLoad()
let value = UIInterfaceOrientation.landscape.rawValue
UIDevice.current.setValue(value, forKey: "orientation")
}
override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return .landscape
}
override var shouldAutorotate: Bool {
return true
}
Upvotes: 1