限制Ionic应用的竖屏方向

15

我正在使用Ionic和Cordova制作一个应用,我尝试将视图的方向限制为仅竖屏,我在config.xml文件中进行了以下配置,但仍无法工作,有什么想法吗?

    <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.ionicframework.ionicucas805049" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
  <name>ionicUcas</name>
  <description>
        An Ionic Framework and Cordova project.
    </description>
  <author email="hi@ionicframework" href="http://ionicframework.com/">
      Ionic Framework Team
    </author>
  <content src="index.html"/>
  <access origin="*"/>
  <preference name="webviewbounce" value="false"/>
  <preference name="UIWebViewBounce" value="false"/>
  <preference name="DisallowOverscroll" value="true"/>
  <preference name="BackupWebStorage" value="none"/>
  <preference name="Orienation" value="portrait" />
  <feature name="StatusBar">
    <param name="ios-package" value="CDVStatusBar" onload="true"/>
  </feature>
</widget>

我已经添加了<preference name="Orienation" value="portrait" />,但没有效果...


这是区分大小写的,请尝试:<preference name="orientation" value="portrait" /> - Dawson Loudon
谢谢Dawson,问题解决了。 - Sole
现在你也可以通过编程来实现这个功能:http://www.gajotres.net/changing-locking-screen-orientation-in-ionic-application/ - Gajotres
可能是如何在Ionic中限制应用程序仅以纵向模式运行的重复问题。 - Vadiem Janssens
1个回答

38
< p > config.xml 中的偏好设置是大小写敏感的,而且(不幸的是)并不一致。

对于这个特定的设置,它全部小写:

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

但在 Apache 文档中,它是 Orientation:http://cordova.apache.org/docs/en/latest/config_ref/index.html - Al-Mothafar

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接