UIWebView has a delay when loading image of the URL


I have problem with UIWebView delay when the load image from url.

In my code are lines to load local html file:

NSBundle *thisBundle = [NSBundle mainBundle];
NSString *path = [thisBundle pathForResource:@"detail" ofType:@"html"];
NSString *html = [NSString stringWithContentsOfFile:path];
NSString *htmlString = [NSString stringWithFormat:html, imageURL];
[webView loadHTMLString:htmlString baseURL:nil];

and one of lines in my detail.html file:

<img src="%@" height="100%" alt="…"></img>

And now when I push the button and go to UIWebView, at first it is white and after few seconds show image and text. I know that time is necessary to load image from URL, but is it possible at first show text and next waiting to load image??

Generally I thinking of: push button -> go to UIWebView -> show text -> show image when it's loaded

There are a few things you could do, one would be to just display a view underneath the uiwebview that displays the text. Set the uiwebview's alpha to be 0 (so its transparent), then when you receive notification that the uiwebview has finished loading use an animation to fade it in, and then remove the view with text.

You will know when the UIWebView has finished loading when the webViewDidFinishLoad: is called.

For the animation something like this:

   [UIView animateWithDuration:0.4
                 animations:^ {
                     self.webView.alpha = 1.0;