在Phonegap构建中延迟iOS上的启动画面(编辑现有的deviceready-function)

时间:2014-06-09 19:27:26

标签: ios cordova splash-screen

我想在iOS的Phonegap Build应用程序中延迟启动画面(并避免白色闪烁)。并把它放在我的config.xml中:

<gap:splash src="splash.png" width="640" height="960" />
<preference name="AutoHideSplashScreen" value="false" />
<gap:plugin name="org.apache.cordova.splashscreen" />
<preference name="FadeSplashScreen" value="true" />
<preference name="SplashScreenDelay" value="1000" />

(&#34; SplashScreenDelay&#34;无效)。我知道我也必须在index.html中添加这样的东西:

function onDeviceReady() {
    setTimeout(function () {navigator.splashscreen.hide()},4000);
        }

但我无法弄清楚如何将其与我现有的index.html相结合。身体看起来像这样:

<body> 
    <div id="fb-root"></div>

    <canvas id="c2canvas" width="640" height="960">
        <h1>Your browser does not appear to support HTML5.  Try upgrading your browser to the latest version.  <a href="http://www.whatbrowser.org">What is a browser?</a>
        <br/><br/><a href="http://www.microsoft.com/windows/internet-explorer/default.aspx">Microsoft Internet Explorer</a><br/>
        <a href="http://www.mozilla.com/firefox/">Mozilla Firefox</a><br/>
        <a href="http://www.google.com/chrome/">Google Chrome</a><br/>
        <a href="http://www.apple.com/safari/download/">Apple Safari</a><br/>
        <a href="http://www.google.com/chromeframe">Google Chrome Frame for Internet Explorer</a><br/></h1>
    </canvas>

    <script src="jquery-2.0.0.min.js"></script>

    <script src="phonegap.js"></script>

    <script src="c2runtime.js"></script>

    <script>
        jQuery(window).resize(function() {
            cr_sizeCanvas(jQuery(window).width(), jQuery(window).height());
        });

        document.addEventListener("deviceready", function ()
        {           
            // Create new runtime using the c2canvas
            cr_createRuntime("c2canvas");

            document.addEventListener("pause", function() {
                cr_setSuspended(true);
            }, false);

            document.addEventListener("resume", function() {
                cr_setSuspended(false);
            }, false);

        }, false);

    </script>
</body>

1 个答案:

答案 0 :(得分:-1)

只需添加:

setTimeout(function () {navigator.splashscreen.hide()},4000);

到你已经拥有的街区:

document.addEventListener("deviceready", function () {
    ...
}