这应该很简单,但实际并不是。我试图防止我的应用程序进入横向视图,因此我已经像这样更改了config.xml
文件:<preference name="orientation" value="portrait" />
。不幸的是,它并没有起作用。有什么想法吗?
这应该很简单,但实际并不是。我试图防止我的应用程序进入横向视图,因此我已经像这样更改了config.xml
文件:<preference name="orientation" value="portrait" />
。不幸的是,它并没有起作用。有什么想法吗?
好的,我明白了:Phonegap忽略了<preference name="orientation" value="portrait" />
在config.xml
文件中的原因是因为我的应用处于调试模式。一旦我创建了一个发布版本,它就停止从横向模式切换到纵向模式。
只需要一小段代码,就可以愉快地开始了。试试看吧。
<preference name="orientation" value="portrait" />
window.addEventListener("orientationchange", function(){
screen.lockOrientation('portrait');
});
thank u
对于 Android 平台,只需在 androidManifest.xml 中设置首选方向,如下所示
<activity
android:name="com.payoda.Insurance.SplashScreenActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar"
>
</activity>
对于IOS,以下链接可能会对您有所帮助