I am working on a Swift framework that requires specific screens to be displayed in a landscape-left orientation, while the rest of the application remains in its default portrait orientation.
I tried these in my ViewController.
UIDevice.current.orientation.isLandscape is true but view not left landscape.
func forceLandscapeOrientation() {
let landscapeOrientation: UIInterfaceOrientation = .landscapeLeft // or .landscapeLeft
UIDevice.current.setValue(landscapeOrientation.rawValue, forKey: "orientation")
}
override public var shouldAutorotate: Bool {
return false
}
// Override to allow only landscape orientations for this view controller
public override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
return .landscapeLeft
}
public override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation {
return .landscapeLeft
}
I am working on a framework that is locked to Portrait mode, but I want to force the orientation to Landscape-Left only for this specific page.