phonegap 3.1 - 无法在设备就绪时隐藏启动画面 [英] phonegap 3.1 - Unable to hide splash screen on device ready

查看:17
本文介绍了phonegap 3.1 - 无法在设备就绪时隐藏启动画面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 phonegap 3.1 我试图在设备准备好时隐藏启动画面:

Using phonegap 3.1 I'm trying to hide the splash screen when device is ready:

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

function onDeviceReady() {
 navigator.splashscreen.hide();
}

但它返回:

无法调用未定义的方法 'hide'

Cannot call method 'hide' of undefined

导航器对象不包括闪屏属性.

The navigator object doesn't including the splashscreen attribute.

我已经在 phonegap 2.9 上试过了,效果很好.

I've tried it on phonegap 2.9 and it works fine.

推荐答案

经过研究和实验,我们必须这样做才能让它发挥作用:

After research and experiments this is what we had to do in order to get it work:

cordova 插件添加 org.apache.cordova.splashscreen

cordova 构建

然后,cordova build 在 config.xml 中添加了错误的行 - 所以我们不得不将其更改为以下内容:

Then, cordova build was adding the wrong lines to the config.xml - So we had to change it to the following:

 <feature name="SplashScreen">
        <param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen" />
 </feature>

在你的主要活动中

 super.setIntegerProperty("splashscreen", R.drawable.splash);
 super.setIntegerProperty("splashScreenDelay", 10000); //time to display the splash

最后,我们可以使用 javascript 中的 hide 方法.

Finally we have been able to use hide method from javascript.

这篇关于phonegap 3.1 - 无法在设备就绪时隐藏启动画面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆