cordova-plugin-screen-orientation
cordova-plugin-screen-orientation copied to clipboard
.lock(ORIENTATIONS.LANDSCAPE) not working in iOS 12 13 if the phone auto rotation is enabled
Bug Report
Problem
I've tested on both iOS 12 and 13. My app is locked through config.xml to allow only portrait mode. I have a page using Ionic 5. When the user navigates to this page I try to lock on landscape and when he leaves I lock on portrait again.
What is expected to happen?
Even if the phone auto-rotation is enabled, the phone should turn to landscape (its a photo gallery page) when he enters the page.
What does actually happen?
If the phone autorotation is disabled the app turns to landscape when he enters the page, but if the phone autorotation is enabled sometimes it rotates and sometimes doesn't. I think the problem is that if the phone is not 100% in portrait mode (lets say you are holding it inclined) or if its already in landscape mode (you are holding it in landscape), the plugin cant manage to turn the orientation.
Information
Command or Code
When the user enters the page:
ionViewWillEnter() {
this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.LANDSCAPE).then((data) => {
});
}
and when user leaves:
ionViewWillLeave() {
this.screenOrientation.lock(this.screenOrientation.ORIENTATIONS.PORTRAIT);
}
Environment, Platform, Device
"cordova-plugin-screen-orientation": "^3.0.2",
"@ionic/angular": "^5.2.2",
ios 12 as 13 on Iphone
Version information
Checklist
- [X] I searched for existing GitHub issues
- [X] I updated all Cordova tooling to most recent version
- [X] I included all the necessary information above
Hi,
I am experiencing the exact same problem. As workaround, I found that adding the following instruction to CDVOrientation.m
at line 84 solved the problem in my case:
[UINavigationController attemptRotationToDeviceOrientation];
I could send a PR if maintainers agree on the solution.
Probably solved by #102 or not relevant anymore today.