WebViewDidFinishLoad: Shooting Too Soon?

I am trying to go between loading various web pages by hiding the webView when the page loads. Nevertheless, I see that some sites that use images intensively cause webViewDidFinishLoading to start too fast, and when I show the webView at this point, you will get an idea of ​​the previous page for a second. Any ideas on how to resolve this?

+12
iphone
Sep 14 '09 at 15:06
source share
2 answers

If there is Javascript on the page, you may need to wait for it to complete. The easiest way is 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 is not completely updated in webViewDidFinishLoad.

+4
Apr 14 '10 at 16:19
source share

I ran into this problem. Although I did not find a solution, I worked on the problem by introducing a delay of 0.5 seconds before showing the UIWebView after calling the delegate method webViewDidFinishLoading.

 - (void)webViewDidFinishLoad:(UIWebView *)webView { [self performSelector:@selector(displayWebView) withObject:nil afterDelay:0.5]; } 
+3
Oct. 25 '09 at 16:45
source share



All Articles