iOS 13/13.1 autorotation seems to be behave differently than iOS 12. For instance, my app allows user to lock interface orientation to portrait or landscape mode in settings.
If I have portrait rotation lock on device and return .landscape in supportedInterfaceOrientations, the interface remains in portrait mode until I disable portrait lock orientation on device. This does not seem to be the case with iOS 12. Infact, supportedInterfaceOrientations is not even called in iOS 13!
UIViewController.attemptRotationToDeviceOrientation() also does not work in such cases.
The root of the problem is I temporarily return shouldAutorotate to false while the app is initializing and when everything is initialized, I call UIViewController.attemptRotationToDeviceOrientation() to trigger autorotation. It triggers autorotation in iOS 12 but in iOS 13.1 it doesn't works.
Looks like a bug in iOS 13.1 probably. What do I do to force trigger autorotation?
EDIT: Looks like iOS 12.4.1 also ignores UIViewController.attemptRotationToDeviceOrientation(). There is something broken in autorotation in iOS 12.4.1 & above.
To be clear, this is what I want:
a. Even if portrait lock is set on iPhone, I wish my interface to autorotate to landscape mode if required,
b. UIViewController.attemptRotationToDeviceOrientation() alternative that triggers autorotation in all circumstances.
Swipe down from the top-right corner of your screen to open Control Center. Tap the Portrait Orientation Lock button to make sure that it's off.
If you've enabled auto-rotate, your Android phone's screen is supposed to rotate when turn your phone 90 degrees or more. Sometimes, though, you might notice that this doesn't happen. It's possible a third-party app, a system glitch, or a faulty sensor is causing your phone not to recognize the movement.
Swipe down from the top right-hand corner of your screen to open Control Centre. Tap the Portrait Orientation Lock button to make sure it's turned off.
From iOS 12.4.1, View Controller should be set to Full Screen to respect the auto-rotate orientation.
let vc = UIViewController()
vc.modalPresentationStyle = .fullScreen
self.present(vc, animated: true, completion: nil)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With