Question

This one should be very simple, however it's not. I'm trying to prevent my application from going into landscape view so I've changed the config.xml file like this: <preference name="orientation" value="portrait" />. Unfortunately, it's not working. Any ideas?

Était-ce utile?

La solution

Ok, so I got it: The reason Phonegap ignored the <preference name="orientation" value="portrait" /> in the config.xml file is because my app was in debug mode. once I created a release version it stopped from going to landscape.

Autres conseils

Small piece of code and here you go. Try it.

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

hello you can install this plugin https://github.com/gbenvenuti/cordova-plugin-screen-orientation

and add this function on you index.js or one of your first executed js document

window.addEventListener("orientationchange", function(){
    screen.lockOrientation('portrait');
});

thank u

For platform android just set prefered orientation in androidManifest.xml like this

 <activity
        android:name="com.payoda.Insurance.SplashScreenActivity"
        android:label="@string/app_name"
        android:screenOrientation="portrait"
        android:theme="@android:style/Theme.Black.NoTitleBar"
    >
    </activity>

For IOS the following link may help you

Force portrait orientation on iPhone with phonegap

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top