0

my iOS Application should be Portrait all the time by default, even if you rotate your device, it should stay Portrait. This is defined in the info.plist.

<key>UISupportedInterfaceOrientations</key>
    <array>
        <string>UIInterfaceOrientationPortrait</string>
    </array>

Now I want to implement, that only in 1 ViewController there is a Button, that changes the screen to Landscape, like so:

var value  = UIInterfaceOrientation.landscapeRight.rawValue
UIDevice.current.setValue(value, forKey: "orientation")
UIViewController.attemptRotationToDeviceOrientation()

but because of the info.plist settings, this does not work. If I remove the property in info.plist, these lines will work, but then the rest of the application will change to landscape, if I rotate the device, which I don't want.

How would you approach and fix this issue?

Can you even support Landscape that is only triggered by Button click?

Thanks in advance!

Karim Omar
  • 11
  • 2
  • Does this answer your question? [How to allow only single UIViewController to rotate in both Landscape and Portrait direction?](https://stackoverflow.com/questions/17466048/how-to-allow-only-single-uiviewcontroller-to-rotate-in-both-landscape-and-portra) – lazarevzubov Sep 26 '22 at 06:25

0 Answers0