问题
I want to hide the screen splah of my app and i'm trying to do this with Cordova function navigator.splashscreen.hide()
according to this
function wlEnvInit(){
wlCommonInit();
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
alert("device is ready!");
navigator.splashscreen.hide();
}
}
I placed this code on android/js/myAppName.js
and iphone/js/myAppName.js
folders. It does not work. There is something wrong?
回答1:
I assume what you're trying to do is to hide the splash image at a point in time based on your own preference? This is currently not possible.
Worklight bypasses Cordova's splash image mechanism as well as does not provide an API to manipulate its duration programmatically (= choose when to hide it). This is an area that is destined to change in a future release.
If what you're trying to do is to simply not show a splash image at all, then:
- In iOS: this is not possible. The splash image is mandatory by Apple
- In Android: simply delete the
splash.9.png
image file from theyourProject\apps\yourApp\android\native\res\drawable
folder
BTW, I do not see the use for the deviceready
listener, because if you've reached wlCommonInit
, then the device (Cordova...) has already been initialized. The app would not have functioned otherwise.
回答2:
For the time being, a workaround for it would be by replacing the Splash screen image with a complete white background screen/image.
来源:https://stackoverflow.com/questions/20428624/ibm-worklight-hiding-splash-screen