Splashscreen没有响应使用JQuery mobile 1.4.3的PhoneGap 3.5中的hide()

时间:2014-08-10 10:41:27

标签: javascript android jquery-mobile cordova splash-screen

我正在构建一个多平台应用程序,但目前我只在Android模拟器中进行测试。我已按照所有步骤显示Splashscreen并使用事件驱动方法隐藏它但我无法这样做,它在加载JQuery移动设备之前隐藏了增强的html,显示约2秒。我的代码如下所示:

的index.html

<head>
    <meta charset="utf-8" />
    <meta name="format-detection" content="telephone=no" />
    <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
    <meta name="msapplication-tap-highlight" content="no" />

    <link rel="stylesheet" href="css/jquery.mobile-1.4.3.min.css">

    <script type="text/javascript" src="cordova.js"></script>
    <script src="js/jquery-1.8.2.min.js"></script>
    <script type="text/javascript" src="js/index.js"></script>
    <script type="text/javascript">
        app.initialize();
    </script>

    <title>Hello World</title>
</head>
<body>
...

index.js

var app = {
  initialize: function() {
    this.bindEvents();
  },

  bindEvents: function() {
    document.addEventListener('deviceready', this.onDeviceReady, false);
  },

  onDeviceReady: function() {
    app.receivedEvent('deviceready');
  },

  receivedEvent: function(id) {
    switch (id) {
      case "deviceready":
        $(document).one("mobileinit", function () {
          $.mobile.pushStateEnabled = false;
          $.support.cors = true;
          $.mobile.allowCrossDomainPages = true;

          navigator.splashscreen.hide();
        });
        $.getScript('js/jquery.mobile-1.4.3.min.js');
        break;

      default:
        break;
    }
  }
};

config.xml中

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.example.hello" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
   <preference name="loglevel" value="DEBUG" />
   <preference name="AndroidLaunchMode" value="singleTop" />
   <feature name="App">
      <param name="android-package" value="org.apache.cordova.App" />
   </feature>
   <feature name="SplashScreen">
      <param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen" />
   </feature>
   <name>HelloWorld</name>
   <description>
      A sample Apache Cordova application that responds to the deviceready event.
   </description>
   <author email="dev@cordova.apache.org" href="http://cordova.io">
      Apache Cordova Team
   </author>
   <content src="index.html" />
   <access origin="*" />
   <preference name="SplashScreen" value="screen" />
   <preference name="SplashScreenDelay" value="150000" />
   <preference name="AutoHideSplashScreen" value="false" />
</widget>

任何人都能看到我做错了什么?

提前致谢!

0 个答案:

没有答案