【问题标题】:Enforce right orientation landscape mode for Phonegap/Cordova iOS app为 Phonegap/Cordova iOS 应用程序强制执行右向横向模式
【发布时间】:2014-04-28 23:32:00
【问题描述】:

是否可以强制您的 Phonegap 应用仅使用正确的横向模式?

我知道这对于原生 iOS 应用是可能的(请参阅 Xcode 中的设置截图)

我唯一能找到的 Phonegap 是 config.xml 中的方向首选项:

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

此首选项强制以横向模式显示应用,但允许您将屏幕旋转 180 度。这不是我们想要的结果。

【问题讨论】:

    标签: javascript ios cordova orientation screen-orientation


    【解决方案1】:

    IOS

    在 config.xml 中设置:

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

    或

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

    在“UISupportedInterfaceOrientations”设置的资源文件夹下的ios文件夹中的“ProjectName”-info.plist文件中:

    UIInterfaceOrientationLandscapeLeft
    

    或

    UIInterfaceOrientationLandscapeRight
    

    或

    纵向:

    UIInterfaceOrientationPortrait
    

    或

    UIInterfaceOrientationPortraitUpsideDown
    

    包括哪些适用于您的要求。

    【讨论】:

      【解决方案2】:

      找到解决方案:

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

      【讨论】:

      • 你在哪里添加的?
      • 在您的 config.xml 文件中。注意:当您使用 build.phonegap.com 构建应用程序时,此解决方案有效。如果您使用 Cordova(本地)构建,您可以在 info.plist 文件中设置屏幕方向设置。在这里您可以找到有关此设置的更多信息:docs.build.phonegap.com/en_US/…
      • 还需要&lt;/gap:config-file&gt;,但没有解决我的问题,即应用程序在 Ipad 上以错误的旋转开始。
      猜你喜欢
      • 2017-01-17
      • 1970-01-01
      • 2012-04-05
      • 2012-02-14
      • 1970-01-01
      • 2010-10-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多