PhoneGap Hello World change orientation

2019-05-10 13:05发布

问题:

This is silly, but if I run phonegap create someApp, and then edit the config.xml file from:

<preference name="orientation" value="default" />

to

<preference name="orientation" value="landscape" />

and run on ios, nothing changes. In fact, its locked in portrait mode. Whats up with this? This is a fresh app, no modifications. Documentation says that this is all there is to it, but it does nothing. Not finding any help anywhere else online... Thanks in advance.

回答1:

Check this http://plugins.cordova.io/#/package/net.yoik.cordova.plugins.screenorientation for possible solution.

I have updated the js/index.js file from the default app:

onDeviceReady: function() {
    app.receivedEvent('deviceready');
    screen.lockOrientation('landscape'); //this is the new line
},

This is just a workaround as now the app works differently on Android and iOS :(