Archive for September 2011
iOS PhoneGap / Cordova – Splash screen control
[UPDATE: for Cordova 1.6.0 instructions see the last section]
Unfortunately a splash screen is still needed to hide the white flash that is visible just before the UIWebView loads its content. Previously before PhoneGap 1.0, you had no control over this – sometimes your content just takes an extra time to load and you want to control the duration of the splash screen.
There are two steps to enable this, firstly – in PhoneGap.plist (Cordova.plist in 1.6.0), change the value for “AutoHideSplashScreen” to false (by default it is true for legacy code). This will not hide the splash screen, and it will remain on screen indefinitely.
Next, in your code, you will have to explicitly hide the splash screen.
After the deviceready event has been fired, you can call this function anytime you are ready:
navigator.splashscreen.hide();
If you want to just delay hiding the splash screen for 2 seconds for example, you can do this in your deviceready event handler:
setTimeout(function() {
navigator.splashscreen.hide();
}, 2000);
Cordova 1.6.0 – the navigator.splashscreen interface has been removed pending cross-platform support. For now use these functions below:
// to hide cordova.exec(null, null, "SplashScreen", "hide", []) // to show cordova.exec(null, null, "SplashScreen", "show", [])