Devlain
September 22, 2016, 1:45pm
1
Good day people!
I’m having an issue with this plugin.
I installed it with cordova plugin add cordova-plugin-screen-orientation
(my cordova is in v6.3.1).
Then I added screen.lockOrientation('landscape')
into my view’s controller, but the console returned me the next status:
TypeError: screen.lockOrientation is not a function
Any ideas of why this could be happening ?
Thanks in advance!
mvrc
September 22, 2016, 1:53pm
2
Do you want to fix the orientation ?
If so, you just have to add <preference name="orientation" value="lanscape" />
in config.xml `.
Devlain
September 22, 2016, 2:01pm
3
Thanks mvrc, but I’m trying to lock orientation depending on current view and the changes in config.xml changes the orientation in all the application.
Devlain
September 22, 2016, 2:56pm
4
I fixed it !
I needed to encapsulate the function like this
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady(){
screen.lockOrientation('landscape'); // or 'portrait'
};
I dunno why I have to do this or why it is not in the documentation, but I think it could help somebody else.