简体   繁体   中英

Can't normally lock landscape orientation on iPhone

I'm using Screen Orientation API ( https://www.w3.org/TR/screen-orientation/ ) for JavaScript. I have the following problem: When I turn iPhone to landscape position (when button is on the left, selfie-cam on the right) it rotates screen normally, but after I invoke screen.orientation.lock('landscape') , it rotates screen and show screen upside-down. It doesn't happen on android. On android when invoking screen.orientation.lock('landscape') , screen stays on landscape mode, as expected. Could you please say, how this can be potentially fixed?

Turns out, that it is known problem of Screen Orientation API. It's even mentioned in github of its library: https://github.com/apache/cordova-plugin-screen-orientation/issues/42 and the issue is still open. So in my case, I just locked orientation to the current landscape, eg if it's 'landscape-secondary', then I use screen.orientation.lock('landscape-primary') . Why 'primary'? Because it mixed up, and if you are now on landscape-secondary and lock on landscape-secondary, then it will anyway rotate to landscape-primary. So the answer is that it's the library issue.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM