【问题标题】:Delaying splash-screen on iOS in Phonegap build (editing existing deviceready-function)在 Phonegap 构建中延迟 iOS 上的闪屏(编辑现有的 deviceready-function)
【发布时间】:2014-08-05 19:48:25
【问题描述】:

我想在我的 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" />

(“SplashScreenDelay”无效)。我知道我还必须在我的 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>

【问题讨论】:

    标签: ios cordova splash-screen


    【解决方案1】:

    只需添加:

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

    到你已经拥有的块:

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

    【讨论】:

    • 感谢您的回答 - 我不是一个程序员,我的问题是我不知道如何确切地添加它。您能否展示如何编写整个
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-04-06
    • 1970-01-01
    • 1970-01-01
    • 2018-04-28
    • 2011-07-20
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多