I'm trying to transition between loading of different web pages by hiding the webView while it is loading a page. However, I'm seeing that some image intensive websites are causing webViewDidFinishLoading to fire too soon and when I show the webView at that point then for a split second you get a view of the previous page. Any ideas on how to resolve this?
Asked
Active
Viewed 5,641 times
12
-
1Encountered this as well. Javascript isn't really ready when the event has already fired :/ – Danra Sep 20 '10 at 16:44
-
I've been struggling with this as well, and suspect that although all the content may have been loaded, the page may not yet have rendered. So you see the old page for a split second. In my case, no Javascript but tons and tons of CSS and a big load of HMTL. – brainjam Jan 21 '14 at 16:19
2 Answers
3
I've encountered this problem as well. Although I haven't found a solution, I've worked around the problem by introducing a 0.5 second delay before showing the UIWebView once the webViewDidFinishLoading delegate method is called.
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
[self performSelector:@selector(displayWebView) withObject:nil afterDelay:0.5];
}

Pieter
- 47
- 2
3
If there's Javascript on the page, you may need to wait for it to finish. The easiest way seems to be to send some javascript to the page to be executed:
-(void) webViewDidFinishLoad:(UIWebView *)webView
{
NSString *javaScript = @"<script type=\"text/javascript\">function myFunction(){return 1+1;}</script>";
[webView stringByEvaluatingJavaScriptFromString:javaScript];
// done here
}
Having said that, I seem to still see cases where the webview isn't quite updated within webViewDidFinishLoad.

Eric Shapiro
- 55
- 2