Cordova 3.x forcing screen orientation at run-time IOS [duplicate]

£可爱£侵袭症+ 提交于 2020-01-06 04:01:22

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!