I am trying to force only one view in my application on landscape mode, I am calling
override func shouldAutorotate() -> Bool {
print(\"shouldAutoro
Swift 4
Trying to keep the orientation nothing worked but this for me:
...
override func viewDidLoad() {
super.viewDidLoad()
forcelandscapeRight()
let notificationCenter = NotificationCenter.default
notificationCenter.addObserver(self, selector: #selector(forcelandscapeRight), name: Notification.Name.UIDeviceOrientationDidChange, object: nil)
}
@objc func forcelandscapeRight() {
let value = UIInterfaceOrientation.landscapeRight.rawValue
UIDevice.current.setValue(value, forKey: "orientation")
}
....