【发布时间】:2020-12-29 20:41:07
【问题描述】:
有没有办法在我启动我的应用程序后立即获取它,然后我得到登录屏幕,然后就可以使用 SplashScreen。
或者一种修改某些东西的方法,让我的动画成为我的 SplashScreen ?
谢谢。
【问题讨论】:
有没有办法在我启动我的应用程序后立即获取它,然后我得到登录屏幕,然后就可以使用 SplashScreen。
或者一种修改某些东西的方法,让我的动画成为我的 SplashScreen ?
谢谢。
【问题讨论】:
在 config.xml 中设置更长的超时时间,并在加载主屏幕时自行禁用它。
config.xml
<preference name="SplashScreenDelay" value="30000" />
app.component.ts
platform.ready().then(() => {
splashScreen.hide();
});
【讨论】:
Ionic默认隐藏闪屏,所以如果闪屏被隐藏但主应用程序还没有准备好或者主页仍然加载一些数据,你会发现白屏!。
建议的解决方案(控制隐藏启动画面):
splashScreen.hide();config.xml
<preference name="AutoHideSplashScreen" value="false" />
app.component.ts 或 home.page.ts
platform.ready().then(() => {
splashScreen.hide();
});
【讨论】:
您可以在生产模式下运行/构建您的应用程序。
对于 Android 构建,例如:ionic cordova build android --prod
对于 Android 运行,例如:ionic cordova run android --prod
【讨论】:
我现在测试的最佳解决方案是:
//Put a long time for splash screen delay to avoid that the splash screen hides and the interface become white:
<preference name="SplashScreenDelay" value="50000" />
//just animation duration before being hided
<preference name="FadeSplashScreenDuration" value="800" />
constructor(
public platform: Platform,
public statusBar: StatusBar,
public splashScreen: SplashScreen
){
// ensure that the interface is loaded by adding 500ms or less before hiding the splash screen manually
this.platform.ready().then(() => {
setTimeout(() => {
this.splashScreen.hide();
}, 500);
});
}
【讨论】: