【问题标题】:cordova[phonegap] Setting splash screen is not working fine in ioscordova [phonegap] 设置启动画面在 ios 中无法正常工作
【发布时间】:2014-11-06 10:24:52
【问题描述】:

我为我的 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="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 上它会在几秒钟后改变闪屏的分辨率。

【问题讨论】:

  • 你做到了吗?

标签: ios cordova phonegap-plugins


【解决方案1】:

安装闪屏插件

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

【讨论】:

  • 嗨shinyJoes,我已经更新了我的问题。请检查一下
【解决方案2】:

如果你有苹果设备构建 uisng Xcode 并在应用程序的主线程中添加睡眠(在应用程序委托中)并且你完成了它

【讨论】:

    猜你喜欢
    • 2021-05-10
    • 2017-09-17
    • 2017-04-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多