Question

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

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top