简体   繁体   English

IONIC 应用程序启动画面后的白屏

[英]White screen after splash screen in IONIC app

I have a "problem" with my app.我的应用程序有“问题”。 When it's running, after the splash screen and before the app is ready, a white screen appears for about 5/6 seconds and it's so annoying.当它运行时,在启动画面之后和应用程序准备好之前,出现白屏大约5/6秒,很烦人。 How is it possible to avoid this white screen?如何避免这种白屏?

I didn't see a lot of questions about this (without working answers) and I would like to have an updated answer.我没有看到很多关于这个的问题(没有有效的答案),我想要一个更新的答案。 I don't post code because I don't know which code could be useful.我不发布代码,因为我不知道哪些代码可能有用。

Ionic version 3.13.2离子版本3.13.2

Thank you.谢谢。

This may be due to the fact that your application takes longer to load than the duration of the splahscreen.这可能是因为您的应用程序加载时间比启动画面的持续时间更长。

In your config.xml file you may have something like:在您的 config.xml 文件中,您可能有以下内容:

<preference name="SplashScreenDelay" value="3000" />

That means that the splashscreen will automatically fade out after 3 seconds.这意味着闪屏将在 3 秒后自动淡出。 However, if your app is not ready after that time, you will see a white screen while your app finishes loading.但是,如果您的应用程序在那段时间之后还没有准备好,您将在应用程序完成加载时看到白屏。

The solution is to set a longer time for your splashscreen and to also turn off AutohideSplashScreen .解决方案是为启动画面设置更长的时间并关闭AutohideSplashScreen In the config.xml file:在 config.xml 文件中:

<preference name="AutohideSplashScreen" value="false" />
<preference name="SplashScreenDelay" value="30000" />

Then you need to make sure that you turn the splashscreen off from inside your app, as soon as your app is ready.然后,您需要确保在您的应用程序准备就绪后立即从应用程序内部关闭启动画面。

Typically in the app.component.ts class constructor:通常在app.component.ts类构造函数中:

this.platform.ready().then(() => {
  this.splashScreen.hide();
});

config.xml config.xml

 <preference name="auto-hide-splash-screen" value="false" /> 
 <preference name="AutoHideSplashScreen" value="false" />

main.js please change main.js请更改

this.platform.ready().then(function () {
        _this.statusBar.styleDefault();
        _this.splashScreen.hide();
    });

to

this.platform.ready().then(function () {
            _this.statusBar.styleDefault();
            setTimeout(function(){
                _this.splashScreen.hide();

            }, 3000);
        });

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM