Shazron's PhoneGap Blog

at Adobe Systems Inc.

iOS PhoneGap – Splash screen control

with 5 comments

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, 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);

Written by shazron

September 15, 2011 at 9:26 pm

Posted in phonegap

5 Responses

Subscribe to comments with RSS.

  1. I did this with javascript and css having a very small size image to cover the screen before the content loads. Down side of that i couldnt use a high res image for the second splash image so i ended having a two separate splash svreens. This really helps. Thanks!

    Kerim Incedayi

    September 15, 2011 at 9:59 pm

  2. Thank you so much for this! I have been looking and struggling for 2 solid days! Works perfectly! :)

    Gemma

    September 20, 2011 at 2:01 pm

  3. Thanks! I have been trying to fix this for a long time!!

    Andy

    October 13, 2011 at 4:42 am

  4. Thanks for your efforts on this important issue Shazron. But – this is not working for me.
    I’m using phonegap-1.1.0 and xcode 4.2

    Changing AutoHideSplashScreen” to No (false is not one of the available options) has no effect.

    Bummer. Any advice?

    Dr. Bob

    October 27, 2011 at 9:29 pm

  5. working great phonegap 1.2 thanks for sharing this :)

    emile818

    November 30, 2011 at 12:47 am


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.