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?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
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.
回答2:
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
回答3:
Small piece of code and here you go. Try it.
<preference name="orientation" value="portrait" />
回答4:
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