在PhoneGap / Cordova 1.5.0中显示闪屏 [英] Showing splash screen in PhoneGap/Cordova 1.5.0

查看:204
本文介绍了在PhoneGap / Cordova 1.5.0中显示闪屏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想让我的启动屏幕显示为我的PhoneGap / Cordova本机iOS应用程序。此行为的默认值或布尔值设置为YES。我试图让屏幕显示2秒。目前,它只显示分秒,然后直接进入应用程序。由于我的应用程式在开始时并未下载任何网路资料,因此载入速度相当快。

I'm trying to get my splash screen to show for my PhoneGap/Cordova native iOS app. The default or boolean for this behavior is set to 'YES'. I'm trying to get the screen to show for 2 seconds. At the moment, it only shows for a split second and then goes right into the app. Since my app does not download any data for the web on start, it loads pretty quickly.

根据这项建议,此解决方案适用于某些应用程式。我使用的是最新的Cordova 1.5.0版本: http://shazronatadobe.wordpress.com/2011/09/15/ios-phonegap-splash-screen-control/

According to this advice, this solution works for some. I'm using the latest Cordova 1.5.0 build: http://shazronatadobe.wordpress.com/2011/09/15/ios-phonegap-splash-screen-control/

我已将AutoHideSplashScreen到Cordova.plist中的NO,我使用这个代码:

I've turned the AutoHideSplashScreen to 'NO' in the Cordova.plist and I'm using this code:

    function onLoad() {
        document.addEventListener("deviceready", onDeviceReady, false);
    }
    setTimeout(function() {
               navigator.splashscreen.hide();
               }, 2000);

我试过将setTimeout函数放在一个函数中,但没有效果。像这样:

I've tried putting the setTimeout function within a function, but to no avail. Like so:

    function onLoad() {
        document.addEventListener("deviceready", onDeviceReady, false);
    }
    function hideSplash() {
        setTimeout(function() {
                   navigator.splashscreen.hide();
                   }, 2000);

    }

然后加载'hideSplash负载。但是无效。

And then loading the 'hideSplash()' when the Body loads. But to no avail.

我的代码有什么问题?

推荐答案

OK,我使用RespectTheCode的建议,并从onLoad函数中删除了设备就绪事件。这是工作代码。我把他们正在学习的完整代码:

OK, I took RespectTheCode's advice and removed the device ready event out of the onLoad function. This is the working code. I'm putting the full code for other's who are learning:

<script>
   document.addEventListener("deviceready", onDeviceReady, false);

    setTimeout(function() {
    navigator.splashscreen.hide();
   }, 1000);
</script>

对于不知道的人,1000是一秒钟。

The 1000 is one second for those who don't know. Will not work for less than one second i.e 500. Splash screen just hangs.

这是为我工作,当我安装和应用程序工作正常,但是,当我重新启动设备(iPad2),启动屏幕挂起像以前的问题(上段),将不会进入应用程序。

This is working for me when I install and app works fine,however, when I restart the device (iPad2) the splash screen hangs like the previous problem (above paragraph) and will not enter the app. Weird bug.

任何人都体验过这个?

和Cordova 1.5.0

I'm on iOS 5.1 building with Xcode 4.3.1 and Cordova 1.5.0

这篇关于在PhoneGap / Cordova 1.5.0中显示闪屏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆