【问题标题】:phonegap ignores orientation: how to force landscape orientation?phonegap 忽略方向:如何强制横向?
【发布时间】:2016-01-09 00:38:21
【问题描述】:

我在 mu config.xml 中有那个

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

但是应用程序以纵向开始,我可以旋转屏幕。

如何强制横向?

我读到: Force “Landscape” orientation mode

不触发事件:

document.addEventListener("orientationchange", function(event){
        switch(window.orientation) 
        {  
            case -90: case 90:
                /* Device is in landscape mode */
                break; 
            default:
                /* Device is in portrait mode */
        }
    });

也没有效果:

<link rel="manifest" href="manifest.json">

也不是这个:

screen.orientation.lock('landscape');

如何强制竖屏模式?

这里是

indelxdk.config.crossawalk.app.xml

<?xml version='1.0' encoding='UTF-8'?>
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:intelxdk="http://xdk.intel.com/ns/v1" id="com.intel.appx.sitechat3.xwalk15" version="0.0.1" android-versionCode="1">
<!--This file is generated by the Intel XDK. Do not edit this file as your edits will be lost.           -->
<!--To change the contents of this file, see the documentation on the intelxdk.config.additions.xml file.-->
<intelxdk:version value="1.0"/>
<intelxdk:cordova-cli version="4.1.2"/>
<name>AP Debug x15 sitechat3</name>
<description>Universal init code for Intel XDK and Cordova device ready detection, as well as within browser.</description>
<author>Intel XDK</author>
<content src="index.html"/>
<access origin="*"/>
<access origin="https:*"/>
<intelxdk:plugin intelxdk:name="StatusBar" intelxdk:value="cordova-plugin-statusbar" intelxdk:version="1.0.0" intelxdk:checksum="b4e7aac6" intelxdk:type="file"/>
<intelxdk:plugin intelxdk:name="Device" intelxdk:value="cordova-plugin-device" intelxdk:version="1.0.1" intelxdk:checksum="adfc61ba" intelxdk:type="file"/>
<intelxdk:plugin intelxdk:name="Splashscreen" intelxdk:value="cordova-plugin-splashscreen" intelxdk:version="2.1.0" intelxdk:checksum="170efb68" intelxdk:type="file"/>
<preference name="android-minSdkVersion" value="14"/>
<preference name="android-targetSdkVersion" value="19"/>
<preference name="android-installLocation" value="auto"/>
<preference name="Fullscreen" value="true"/>
<preference name="Orientation" value="landscape"/>
<intelxdk:crosswalk version="15"/>
<!--creationInfo:{"src":"jsapp/template-blank-cordova-project-lite/sample.zip","projectTypeName":"com.intel.xdk.projecttype.jsapp"}-->
<preference name="debuggable" value="false"/>
<platform name="ios">
    <!-- below requires the splash screen plugin -->
    <!-- docs: https://github.com/apache/cordova-plugin-splashscreen -->
    <preference name="AutoHideSplashScreen" value="false"/>
    <preference name="FadeSplashScreen" value="false"/>
    <preference name="FadeSplashScreenDuration" value="2"/>
    <preference name="ShowSplashScreenSpinner" value="false"/>

    <!-- below requires the status bar plugin -->
    <!-- docs: https://github.com/apache/cordova-plugin-statusbar -->
    <!-- see http://devgirl.org/2014/07/31/phonegap-developers-guid -->
    <preference name="StatusBarOverlaysWebView" value="false"/>
    <preference name="StatusBarBackgroundColor" value="#000000"/>
    <preference name="StatusBarStyle" value="lightcontent"/>
</platform>
<platform name="android">
    <!-- below requires the splash screen plugin -->
    <!-- docs: https://github.com/apache/cordova-plugin-splashscreen -->
    <preference name="SplashMaintainAspectRatio" value="false"/>
</platform>
<intelxdk:crosswalk xmlns:intelxdk="http://xdk.intel.com/ns/v1" xwalk-command-line="--disable-pull-to-refresh-effect"/>
<intelxdk:crosswalk xmlns:intelxdk="http://xdk.intel.com/ns/v1" xwalk-command-line="--ignore-gpu-blacklist"/></widget>

【问题讨论】:

  • 你能解析整个 config.xml 吗?

标签: cordova intel-xdk


【解决方案1】:

@Yarkek,

您需要设置更高的编译器版本来实现最新的修复。 Cordova 目前为 5.2.0,您在此处设置为 4.1.2&lt;intelxdk:cordova-cli version="4.1.2"/&gt;。但这还不够。当您升级时,您应该知道您会遇到什么:

阅读:Top Mistakes by Developers new to Cordova/Phonegap
6。没有为你的编译器设置“phonegap 版本”

我引用

使用 CLI 版本,如果您没有为您的平台或“Phonegap Build”分配版本,如果您没有在 config.xml 中设置 phonegap-version,您将获得最新版本。如果幸运的话,您的程序会按预期运行。如果你不走运,你会得到一组级联错误。

幸运的是,Holly Schinsky 写了一篇很好的博文来解释这一切:

Cordova/PhoneGap 版本混乱
http://devgirl.org/2014/11/07/cordovaphonegap-version-confusion/

需要明确的是,您*可能*需要升级您的 Cordova _并且_从头开始重新启动您的项目。我还建议在所有插件上设置版本。

祝你好运

【讨论】:

    【解决方案2】:

    查看这个屏幕方向插件:cordova-plugin-screen-orientation - 给定您的标签,我假设您使用的是英特尔 XDK。您可以在插件管理器工具的特色插件列表中找到它,从“项目”选项卡访问它。

    【讨论】:

      猜你喜欢
      • 2012-04-05
      • 2015-12-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多