【问题标题】:hide splashscreen after InAppBroswer has finished loadingInAppBroswer 完成加载后隐藏启动画面
【发布时间】:2016-02-28 11:48:53
【问题描述】:

我在延迟 IOS 和 Android 上的启动画面时遇到问题,并且只有在 InAppBroswer 完成后才将其删除。这是我尝试过的逻辑

config.xml

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

index.html

<html>
<head>
<title>Example App</title>
<meta charset="utf-8">
<link href="css/index.css" rel="stylesheet" type="text/css">
</head>


<script src="cordova.js" type="text/javascript" ></script>
<script src="js/main.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8">

// Wait for device API libraries to load
//
document.addEventListener("deviceready", onDeviceReady, false);

// Global InAppBrowser reference
var iabRef = null;


function onDeviceReady() {
iabRef = window.open('https://www.example.com/app', '_self', 'location=no,toolbar=no');

iabRef.addEventListener('loadstop', function() { 
    navigator.splashscreen.hide();
});

document.addEventListener("backbutton", function (e) {
e.preventDefault();
}, false );
}
</script>
<body>
<iframe src="https://www.example.com/app" style="width:100%; height:100%;">
</body>
</html>

闪屏显示片刻,然后白屏大约 5 秒。

索引中的逻辑是在 inAppBroswer 完成加载(loadstop) 后隐藏启动画面,但这似乎不起作用。

请有任何想法。

console.log(导航器)

【问题讨论】:

    标签: cordova phonegap-plugins phonegap-build splash-screen inappbrowser


    【解决方案1】:

    页面加载完成后,Inappbrowser 有一个回调。

    阅读documentation。见addEventListener

    它可能看起来像这样:

    ref.addEventListener('loadstop', function() {
        navigator.splashscreen.hide();
    });
    

    【讨论】:

    • 是 navigator.splashscreen.hide();意味着返回真或假?你有什么想法吗,因为在我尝试提醒或控制台记录它的那一刻。我未定义请查看 console.log(navigator) 为splashscreen显示的问题@
    • navigator.splashscreen.hide(); 既不返回 true 也不返回 false,如果有的话,它将返回 'undefined' - 这是假的。本文将帮助Truthy and Falsy: When All is Not Equal in JavaScript
    • 感谢那篇文章只是提醒我为什么我不太喜欢 javascript。为什么让我想到手头的问题。如果navigator.splashscreen.hide() 既不返回true 也不返回false,那么你怎么知道它的工作与否。
    • falsey == falsefalse === false。还有if (falsey) {nothinghappens(); } else {thishappens();}if (false === false) { nothinghappens() } else { thishappens(); } 总而言之,当您与=== 进行比较时,它会比较对象类型和布尔比较;这样两者都必须满足。 --- 您遇到的困惑可能是因为您正在考虑编译语言和严格类型。 (type 是名词) JavaScript 被解释和松散类型。 (再次 type 是名词)。
    • 糟糕,这是错误的。这是正确的: if (false === false) { THIShappens(); } 其他 { 什么都没有(); }
    【解决方案2】:

    他们似乎是最新更新中与启动画面有关的错误,您似乎无法将AutoHideSplashScreen设置为false然后同时使用SplashScreenDelay

    但是

    似乎工作正常,因为我认为 navigator.splashscreen.hide(); 也可以工作

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-26
      • 1970-01-01
      • 2013-02-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多