简体   繁体   English

为Phonegap / Cordova iOS应用程序强制实现正确的方向横向模式

[英]Enforce right orientation landscape mode for Phonegap/Cordova iOS app

Is it possible to enforce your Phonegap app to use right landscape orientation mode only? 是否可以强制您的Phonegap应用程序仅使用正确的横向模式?

I know this is possible for a native iOS app (see screenshot of setting in Xcode) 我知道这对于原生iOS应用程序是可行的(参见Xcode中的设置截图) 在此输入图像描述

The only thing for Phonegap I can find is the orientation preference in the config.xml: 我可以找到的Phonegap唯一的东西是config.xml中的方向首选项:

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

This preference enforces to show the app in landscape mode but allows you to rotate your screen 180 degrees. 此首选项强制以横向模式显示应用程序,但允许您将屏幕旋转180度。 This isn't the desired result. 这不是理想的结果。

For IOS 对于IOS

In config.xml set: 在config.xml中设置:

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

or 要么

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

In "ProjectName"-info.plist file in ios folder under resources folder for "UISupportedInterfaceOrientations" set: 在“ProjectName”-info.plist文件中,在“UISupportedInterfaceOrientations”的资源文件夹下的ios文件夹中设置:

UIInterfaceOrientationLandscapeLeft

or 要么

UIInterfaceOrientationLandscapeRight

or 要么

for portrait orientation: 纵向:

UIInterfaceOrientationPortrait

or 要么

UIInterfaceOrientationPortraitUpsideDown

Include which is applicable for your requirements. 包括适用于您的要求。

Solution found: 解决方案:

<gap:config-file platform="ios" parent="UISupportedInterfaceOrientations" overwrite="true">
<array>
    <string>UIInterfaceOrientationLandscapeRight</string>
</array>

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

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