cordova [phonegap]设置启动画面在ios中无法正常工作

时间:2014-11-06 10:24:52

标签: ios cordova phonegap-plugins

我为我的phonegap应用添加了启动画面

我正在 http://build.phonegap.com 在线构建phonegap应用。

启动画面工作罚款安卓。但在定义的时间之前 ios启动画面隐藏

Config.xml 对于启动画面

    <?xml version="1.0" encoding="UTF-8" ?>
    <widget xmlns   = "http://www.w3.org/ns/widgets"
        xmlns:gap   = "http://phonegap.com/ns/1.0"
        xmlns:android   = "http://schemas.android.com/apk/res/android"
        id          = "com.clerisy.arcade"
        versionCode = "10" 
        version     = "1.0.0" >

    <!-- versionCode is optional and Android only -->

    <name>xxxxxxxxxxxxx</name>

    <description>
        xxxxxxxxxxxxxxxxx
    </description>

    <author href="https://build.phonegap.com" email="support@phonegap.com">
        xxxxxxxxxxxxxxxx
    </author>

    <preference name="permissions" value="none"/>
    <preference name="phonegap-version" value="3.6.3" />
    <preference name="orientation" value="default" />
    <preference name="target-device" value="universal" /> 
    <preference name="fullscreen" value="false" /> 
    <preference name="webviewbounce" value="true" />
    <preference name="prerendered-icon" value="true" />
    <preference name="stay-in-webview" value="false" /> 
    <preference name="ios-statusbarstyle" value="black-opaque" /> 
    <preference name="detect-data-types" value="true" /> 
    <preference name="exit-on-suspend" value="false" /> 
    <preference name="show-splash-screen-spinner" value="true" /> 
    <preference name="auto-hide-splash-screen" value="true" />
    <preference name="disable-cursor" value="false" /> 
    <preference name="android-minSdkVersion" value="7" /> 
    <preference name="android-installLocation" value="auto" /> 
    <preference name="backgroundColor" value="0xff38c0f4"/>
    <preference name="AutoHideSplashScreen" value="false" />   
    <preference name="ShowSplashScreenSpinner" value="false" /> 

    <!-- Plugins -->
    <!-- Core plugins -->

    <gap:plugin name="org.apache.cordova.inappbrowser" version="0.5.2" />
    <gap:plugin name="org.apache.cordova.network-information" version="0.2.12" />
    <gap:plugin name="nl.x-services.plugins.socialsharing" version="4.3.8" />
    <gap:plugin name="org.apache.cordova.device" version="0.2.12" />
    <gap:plugin name="com.phonegap.plugin.statusbar" version="1.1.0" />
    <gap:plugin name="org.apache.cordova.splashscreen" />

    <!-- Set Icon and splash screen -->

    <icon src="icon.png" platform="android" width="57" height="57" density="mdpi" />
    <gap:splash src="screen.png"/>  
    <gap:config-file platform="ios" parent="CFBundleShortVersionString">
    <string>100</string>
    </gap:config-file>
    <content src="index.html" />
    <access origin="*" />
</widget>

隐藏我正在使用的启动画面

document.addEventListener("deviceready", onDeviceReady, false);

function onDeviceReady() {
   // Hide splash Screen
   setTimeout(function() {
            navigator.splashscreen.hide();
        }, 2000);

问题是: -

它在Android上工作正常,但在iPhone上它会在几秒后改变启动画面的分辨率。

2 个答案:

答案 0 :(得分:2)

安装启动画面插件

cordova plugin add org.apache.cordova.splashscreen

对于iOS,您必须在文档就绪中隐藏超时功能中的启动画面,您可以定义启动画面应隐藏的持续时间。

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

在config.xml中将autohide splash设置为false

<preference name="AutoHideSplashScreen" value="false" />

请参阅插件文档以获取更多详细信息https://github.com/apache/cordova-plugin-splashscreen/blob/master/doc/index.md

答案 1 :(得分:0)

如果您使用Xcode构建Apple设备并在app的主线程中添加sleep(在app delegate中)并且您已完成它