【问题标题】:Meteor Cordova: How can I have portrait only orientation on iPhone and portrait and landscape on iPadMeteor Cordova:我怎样才能在 iPhone 上设置纵向,在 iPad 上设置纵向和横向
【发布时间】:2015-12-31 21:43:07
【问题描述】:

我正在尝试设置我的 mobile-config.js 文件,这样对于 iphone,它只能是纵向的,对于 ipad,它可以是纵向或横向的。

但我想不通,关于如何做到这一点的信息也很少。 http://docs.meteor.com/#/full/App-info

meteor 文档指定如何根据 iOS 和 Android 等操作系统锁定方向,但现在如何根据设备自定义方向。

我该怎么做?

【问题讨论】:

  • App.setPreference('Orientation', 'default');在 iPhone/iPod 上显示纵向,在 iPad 上显示所有方向,如果它不起作用,则存在错误。但是您不能按设备更改它(还)

标签: cordova meteor


【解决方案1】:

我不确定您是否可以直接使用流星设置根据设备类型自定义方向。

但是,如果您在本地构建应用程序,您可以手动编辑项目的 iOS .plist 并设置以下键:

<key>UIInterfaceOrientation</key>
<array>
  <string>UIInterfaceOrientationPortrait</string>
</array>
<key>UISupportedInterfaceOrientations</key>
<array>
  <string>UIInterfaceOrientationPortrait</string>
  <string>UIInterfaceOrientationPortraitUpsideDown</string>
</array>
<key>UISupportedInterfaceOrientations~ipad</key>
<array>
  <string>UIInterfaceOrientationPortrait</string>
  <string>UIInterfaceOrientationLandscapeLeft</string>
  <string>UIInterfaceOrientationPortraitUpsideDown</string>
  <string>UIInterfaceOrientationLandscapeRight</string>
</array>

如果您使用云服务(或本地)进行构建,您可以通过将配置添加到您的 config.xml 并在您的项目中包含 cordova-custom-config 插件来应用它来设置这些首选项。 您将以下内容添加到您的 config.xml:

<platform name="ios">
    <!-- Set orientation on iPhone -->
    <config-file platform="ios" target="*-Info.plist" parent="UISupportedInterfaceOrientations">
        <array>
            <string>UIInterfaceOrientationPortrait</string>
            <string>UIInterfaceOrientationPortraitUpsideDown</string>
        </array>
    </config-file>

    <!-- Set orientation on iPad -->
    <config-file platform="ios" target="*-Info.plist" parent="UISupportedInterfaceOrientations~ipad">
        <array>
            <string>UIInterfaceOrientationPortrait</string>
          <string>UIInterfaceOrientationLandscapeLeft</string>
          <string>UIInterfaceOrientationPortraitUpsideDown</string>
          <string>UIInterfaceOrientationLandscapeRight</string>>
        </array>
    </config-file>
</platform>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-06-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多