我正在寻找一种方法来控制我的闪屏显示的时间。由于我必须在用户可以与UI交互之前下载数据,因此此时间不固定。
我的问题是我无法防止启动画面在Android上自动隐藏,在iOS上我将其添加到我的config.xml
<feature name="SplashScreen">
<param name="ios-package" value="CDVSplashScreen"/>
<param name="onload" value="true" />
</feature>
这是我的config.xml
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<widget id="com.example.my" version="1.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>my example</name>
<description>
an example app
</description>
<content src="index.html"/>
<access origin="*"/>
<preference name="webviewbounce" value="false"/>
<preference name="UIWebViewBounce" value="false"/>
<preference name="DisallowOverscroll" value="true"/>
<preference name="android-minSdkVersion" value="19"/>
<preference name="BackupWebStorage" value="none"/>
<preference name="SplashScreenDelay" value="5000" />
<preference name="auto-hide-splash-screen" value="false" />
<preference name="AutoHideSplashScreen" value="false" />
<preference name="orientation" value="portrait"/>
<preference name="SplashMaintainAspectRatio" value="true"/>
<feature name="StatusBar">
<param name="ios-package" onload="true" value="CDVStatusBar"/>
</feature>
<feature name="SplashScreen">
<param name="ios-package" value="CDVSplashScreen"/>
<param name="onload" value="true" />
</feature>
<feature name="SplashScreen">
<param name="android-package" value="org.apache.cordova.splashscreen.SplashScreen"/>
<param name="onload" value="true" />
</feature>
<platform name="android">
<splash src="resources/android/splash/drawable-port-ldpi-screen.png" density="port-ldpi"/>
<splash src="resources/android/splash/drawable-port-mdpi-screen.png" density="port-mdpi"/>
<splash src="resources/android/splash/drawable-port-hdpi-screen.png" density="port-hdpi"/>
<splash src="resources/android/splash/drawable-port-xhdpi-screen.png" density="port-xhdpi"/>
<splash src="resources/android/splash/drawable-port-xxhdpi-screen.png" density="port-xxhdpi"/>
<splash src="resources/android/splash/drawable-port-xxxhdpi-screen.png" density="port-xxxhdpi"/>
<icon src="resources/android/icon/drawable-ldpi-icon.png" density="ldpi"/>
<icon src="resources/android/icon/drawable-mdpi-icon.png" density="mdpi"/>
<icon src="resources/android/icon/drawable-hdpi-icon.png" density="hdpi"/>
<icon src="resources/android/icon/drawable-xhdpi-icon.png" density="xhdpi"/>
<icon src="resources/android/icon/drawable-xxhdpi-icon.png" density="xxhdpi"/>
<icon src="resources/android/icon/drawable-xxxhdpi-icon.png" density="xxxhdpi"/>
</platform>
<platform name="ios">
<splash src="resources/ios/splash/Default-568h@2x~iphone.png" width="640" height="1136"/>
<splash src="resources/ios/splash/Default-667h.png" width="750" height="1334"/>
<splash src="resources/ios/splash/Default-736h.png" width="1242" height="2208"/>
<splash src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" height="2048"/>
<splash src="resources/ios/splash/Default-Portrait~ipad.png" width="768" height="1024"/>
<splash src="resources/ios/splash/Default@2x~iphone.png" width="640" height="960"/>
<splash src="resources/ios/splash/Default~iphone.png" width="320" height="480"/>
<icon src="resources/ios/icon/icon.png" width="57" height="57"/>
<icon src="resources/ios/icon/icon@2x.png" width="114" height="114"/>
<icon src="resources/ios/icon/icon-40.png" width="40" height="40"/>
<icon src="resources/ios/icon/icon-40@2x.png" width="80" height="80"/>
<icon src="resources/ios/icon/icon-40@3x.png" width="120" height="120"/>
<icon src="resources/ios/icon/icon-50.png" width="50" height="50"/>
<icon src="resources/ios/icon/icon-50@2x.png" width="100" height="100"/>
<icon src="resources/ios/icon/icon-60.png" width="60" height="60"/>
<icon src="resources/ios/icon/icon-60@2x.png" width="120" height="120"/>
<icon src="resources/ios/icon/icon-60@3x.png" width="180" height="180"/>
<icon src="resources/ios/icon/icon-72.png" width="72" height="72"/>
<icon src="resources/ios/icon/icon-72@2x.png" width="144" height="144"/>
<icon src="resources/ios/icon/icon-76.png" width="76" height="76"/>
<icon src="resources/ios/icon/icon-76@2x.png" width="152" height="152"/>
<icon src="resources/ios/icon/icon-83.5@2x.png" width="167" height="167"/>
<icon src="resources/ios/icon/icon-small.png" width="29" height="29"/>
<icon src="resources/ios/icon/icon-small@2x.png" width="58" height="58"/>
<icon src="resources/ios/icon/icon-small@3x.png" width="87" height="87"/>
</platform>
<icon src="resources/android/icon/drawable-xhdpi-icon.png"/>
<plugin name="com.telerik.plugins.nativepagetransitions" spec="~0.6.5"/>
<plugin name="phonegap-plugin-push" spec="~1.8.1">
<variable name="SENDER_ID" value="xxxxxxxxx"/>
</plugin>
<plugin name="cordova-plugin-console" spec="~1.0.3"/>
<plugin name="cordova-plugin-splashscreen" spec="~3.1.0"/>
<plugin name="cordova-plugin-badge" spec="~0.7.2"/>
</widget>
我是否需要添加一个特殊的参数/功能config.xml
?
编辑:
如果我更改了SplashScreenDelay
值,那么在我发送navigator.splashscreen.hide();
答案 0 :(得分:0)
尝试添加下一个参数:
<preference name="SplashShowOnlyFirstTime" value="false" />
答案 1 :(得分:0)
我可以从config.xml
收集您正在使用cordova-plugin-splashscreen@3.1.0
的内容,但您应该更新该插件。
阅读插件的Release Notes 3.2.0应该已经为您提供了所需的信息。据我所知,bug fixes
版本中有两个3.2.0
,关于您的问题......
从CLI
更新应该会为您提供最新的插件版本:
cordova plugins remove cordova-plugin-splashscreen
cordova plugins add cordova-plugin-splashscreen
答案 2 :(得分:0)
我修复了这个在每个平台标签内添加不同的偏好
Windows > Preferences > Team > Jazz Source Control > External Compare Tool
修改强> 这是完整的代码:
<platform name="android">
<preference name="StatusBarBackgroundColor" value="#93bc26" />
<preference name="android-minSdkVersion" value="19" />
<preference name="SplashScreenDelay" value="50000" />
<preference name="SplashMaintainAspectRatio" value="true" />
<preference name="SplashShowOnlyFirstTime" value="false" />
</platform>
<platform name="ios">
<preference name="SplashScreenDelay" value="1000" />
<preference name="deployment-target" value="7.0"/>
</platform>
答案 3 :(得分:0)
添加
<preference name="SplashShowOnlyFirstTime" value="false" />
删除此项,设置最大延迟并在未加载应用程序时显示白屏
<preference name="SplashScreenDelay" value="5000" />
在您的app.component的构造函数上
constructor(
public platform: Platform,
public statusBar: StatusBar,
public splashScreen: SplashScreen,
this.platform.ready().then(() => {
splashScreen.hide();
}
}
然后从ionic-native插件导入
import { SplashScreen } from '@ionic-native/splash-screen';