Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

White screen flash after launch image using Phonegap

After loading the launch image, I get a white screen before my application loads. I am using phonegap with xcode. I would like my app to load on my lauch image so that it follows the ios developer guidelines and provides a smooth looking launch. I think this white screen is a webview loading for my application. I would like for this webview to be clear. Any ideas on a fix for this problem or a workaround?

I have attempted the following code and it made no difference on my launch. This code is located in my MainViewController.m

-void (webViewDidFinishLoad:(UIWebView*) theWebView
{
theWebView.backgroundColor = [UIColor clearColor];
theWebView.opaque = NO;
 }

I have researched this a lot but I haven't found a solution.

like image 493
stat8 Avatar asked Jul 02 '12 20:07

stat8


2 Answers

I had faced the same problem too, try these 3 steps which I did to solve the issue:

  1. set AutoHideSplashScreen to NO in your phonegap/cordova plist file

  2. Add this line to your viewDidLoad method of CDVMainViewController.m

    self.useSplashScreen = YES;
    
  3. Then add this code to onDeviceReady() method

    function onDeviceReady()
    {
    // do your thing!
    cordova.exec(null, null, "SplashScreen", "hide", []);  //On Cordova 1.6. 0
    }
    
like image 181
sujithra s Avatar answered Oct 14 '22 23:10

sujithra s


You will have to overlay a ModalViewController that is faking the "Default.png" image after launch, overlay the view controller on top of the UIWebView, and show a UIActivityIndicator, so the user knows you are loading your app. Once the webpage is done, you can dismiss your view controller.

Hope this helps.

like image 45
Oscar Gomez Avatar answered Oct 15 '22 01:10

Oscar Gomez