If you want to force Particular viewController rotate to landscape only then add the following code in AppDelega file
public var orientationLock = UIInterfaceOrientationMask.all
static var shared : AppDelegate {
return UIApplication.shared.delegate as! AppDelegate
}
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
return self.orientationLock
}
func lockDeviceOrientation(orientationLock: UIInterfaceOrientationMask, rotateOrientation:UIInterfaceOrientation) {
AppDelegate.shared.orientationLock = orientationLock
UIDevice.current.setValue(rotateOrientation.rawValue, forKey: "orientation")
}
And add the following code in particular viewController which you want to force to rotate in landscape only
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
AppDelegate.shared.orientationLock = .landscapeLeft
}