转自:http://blog.csdn.net/dounainaicsdn/article/details/50767667
ionic项目中,在splashscreen消失后会出现零点几秒的白屏,再出现app页面,通过Google以及各种尝试,下面方法解决:
1. 安装Cordova splash screen插件
- $ cd myapp
- $ ionic plugin add org.apache.cordova.splashscreen
2. 修改ionic项目的config.xml 文件,
- <preference name="AutoHideSplashScreen" value="false"/>
- <preference name="ShowSplashScreenSpinner" value="false"/>
- <preference name="SplashMaintainAspectRatio" value="true"/>
- <preference name="SplashShowOnlyFirstTime" value="false"/>
- <preference name="SplashScreenDelay" value="10000"/>
- <preference name="FadeSplashScreen" value="false"/>
即不让闪屏自动隐藏,而在代码中手动隐藏splash screen
3. 在app.js中添加隐藏闪屏代码
- $ionicPlatform.ready(function () {
- if (window.cordova && window.cordova.plugins.Keyboard) {
- cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
-
- cordova.plugins.Keyboard.disableScroll(true);
-
- //延迟splash screnn 隐藏时间,不然会有短暂的白屏出现
- setTimeout(function () {
- navigator.splashscreen.hide();
- }, 1000);
- }
- });
-