简体   繁体   English

jQuery手机屏幕方向-Cordova项目

[英]Jquery mobile screen orientation - Cordova project

I am working on Cordova mobile application with Jquery Mobile and I installed my app on my Android mobile but i do not want the screen orientation in landscape how can i disable this feature in Cordova and Jquery mobile? 我正在使用Jquery Mobile开发Cordova移动应用程序,并且将我的应用程序安装在Android移动设备上,但我不希望屏幕横向显示,如何在Cordova和Jquery mobile中禁用此功能? thanks. 谢谢。

Static orientation locking 静态方向锁定

If you are using PhoneGap Build , add this to your config.xml 如果您正在使用PhoneGap Build ,请将其添加到您的config.xml中

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

If not, you need to modify configuration for each platform ( manifest.xml , plist ) separately to include directive for this. 如果不是,则需要分别修改每个平台的配置( manifest.xmlplist )以包括此指令。

For Android, add 对于Android,添加

android:screenOrientation="landscape"

to activity tag, like this 像这样的活动标签

<activity android:name="MyActivity"
  android:screenOrientation="landscape"

For iOS, add 对于iOS,添加

UISupportedInterfaceOrientations

with value 有价值

UIInterfaceOrientationLandscapeLeft

or 要么

UIInterfaceOrientationLandscapeRight

to plist . 列出

Dynamic orientation locking 动态方向锁定

If you instead want to change the orientation per view basis, you can use Cordova plugin by yoik to adjust the orientations dynamically from your JavaScript code like this 如果您想更改每个视图的方向,则可以使用yoik的Cordova插件从JavaScript代码动态调整方向,如下所示

screen.lockOrientation("landscape");

and unlock with 并用解锁

screen.unlockOrientation();

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM