且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

启动屏幕后,PhoneGap Build iOS应用程序有空白屏幕

更新时间:2023-01-25 21:53:00

完全感受到你的痛苦。 PhoneGap Build的文档需要大量工作。
我自己过去几天一直在和这个人打架。经过多次试验和错误后,这对我有用。

Totally feel your pain on this. The docs for PhoneGap Build need a lot of work. I've been fighting with this the last couple of days myself. After much trial and error, this is what has worked for me.

在config.xml中:

<!-- Do not auto hide splash on iOS -->
<preference name="AutoHideSplashScreen" value="false" />
<!-- Do not auto hide splash on Android -->
<preference name="SplashScreenDelay" value="10000"/>

<gap:plugin name="org.apache.cordova.splashscreen" />

Android似乎没有AutoHide参数,所以我们只是给它一个很长的延迟。在达到这10秒之前,我们将使用JS手动隐藏它。

Android does not seem to have an AutoHide param, so we just give it a long delay. We will hide it manually with JS before this 10 seconds is reached.

javascript代码需要在config.xml中添加插件引用navigator.splashscreen.hide(); 工作。

Adding the plugin reference in the config.xml is needed for the javascript code navigator.splashscreen.hide(); to work.

此外,我发现我的项目(使用Kendo UI Mobile)没有setTimeout延迟在 onDeviceReady 中需要。我猜,一旦你在config.xml中得到了正确的参数,你就会在你的应用中看到相同的。

Also, I found for my project (using Kendo UI Mobile) that no setTimeout delay was needed within onDeviceReady. I am guessing, that once you get the correct params within your config.xml, you will see the same in your app.

我的 onDeviceReady 看起来像这样:

document.addEventListener('deviceready', function() {
  navigator.splashscreen.hide();
});

使用PhoneGap Build 3.1在iOS 6和Android 4.1上测试。

Tested on iOS 6, and Android 4.1 using PhoneGap Build 3.1.