OGeek|极客世界-中国程序员成长平台

标题: ios - cordova [phonegap] 设置启动画面在 ios 中无法正常工作 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 12:33
标题: ios - cordova [phonegap] 设置启动画面在 ios 中无法正常工作

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

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

启动画面适用于 android。但在 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="[email protected]">
        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 上它会在几秒钟后改变闪屏的分辨率。



Best Answer-推荐答案


安装闪屏插件

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

关于ios - cordova [phonegap] 设置启动画面在 ios 中无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26777044/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4