简体   繁体   中英

Ability to lock orientation of device with JavaScript in PhoneGap/Cordova

I'm looking for a way to programatically lock the orientation of a device in a PhoneGap/Cordova application using JavaScript for certain pages only.

I am aware that in can be locked globally in the config.xml file but I am searching for a solution that supports both iOS and Android whereby I can lock the orientation using a checkbox/radio control on a single page in my App.

I have found some possible Cordova plugins but they are all Android only.

I am willing to write a Cordova/PhoneGap plugin but I am not sure of the Objective-C and Java code required to lock the orientation using the various native API's.

Here is a great example of what I'm looking for (this is Android only but I need support for both iOS & Android): https://github.com/Hless/cordova-plugin-orientationchanger

Any advice would be greatly appreciated.

Many Thanks, XigenBen

*Remember this plugin only works in android and only if you put this: phonegap.js instead of cordova.js

I stumbled across a plugin on the Cordova plugin registry that solves this exact issue, here's the URL for anyone interested: http://plugins.cordova.io/#/package/net.yoik.cordova.plugins.screenorientation

Can also be found on GitHub: https://github.com/yoik/cordova-yoik-screenorientation

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