问题
I'm building an app with cordova where forcing screen orientation at runtime on certain pages is crucial. I found a plugin com.phonegap.plugins.OrientationLock that works very well on android devices but I can't find any solution for IOS... Have anyone solved this issue? Thank you
回答1:
Updated response:
I just found a plugin that enables this: https://github.com/Adlotto/cordova-plugin-recheck-screen-orientation.
Tested and verified on an iPhone 5 with iOS 7.1 - hooray!
Original response:
I haven't yet found a way to force it on iOS, but it's possible to at least choose which orientations are allowed dynamically at run-time.
That requires a global shouldRotateToOrientation(degree) function that returns true or false based on the device's new orientation. More details here: https://groups.google.com/forum/#!topic/phonegap/xw7QSJVCf5I
You could, theoretically, ask the user to rotate their device when needed, and then "lock" it in place by disallowing further rotations. (Not the ideal solution, of course.)
来源:https://stackoverflow.com/questions/22607226/cordova-3-x-forcing-screen-orientation-at-run-time-ios