Levan Karanadze
Levan Karanadze

Reputation: 461

Swift 5 - How to change device orientation manually on iPad

I have the code that changes the device orientation on button tap (Even if device is not rotated).

override public var shouldAutorotate: Bool {
    return true
}

func rotate() {
    let value = nextDeviceOrientation() // My func that returns new device orientation
    UIDevice.current.setValue(value, forKey: "orientation")
    UINavigationController.attemptRotationToDeviceOrientation()
}

This code works for iPhones only. On iPads it has no effect.

How can I change device orientation manually on iPad?

Upvotes: 0

Views: 215

Answers (1)

Levan Karanadze
Levan Karanadze

Reputation: 461

One solution is to check Requires full screen. I don't know if there is any other way.

Upvotes: 1

Related Questions