Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIWebView: when did a page really finish loading?

I need to know, when a web page has completely been loaded by UIWebView. I mean, really completely, when all redirects are done and dynamically loaded content is ready. I tried injecting javascript (querying for document.readyState == 'complete'), but that does not seem to be very reliable.

Is there, maybe, an event from the private api that will bring me the result?

like image 265
Sebastian Avatar asked Jun 12 '12 11:06

Sebastian


2 Answers

I have been looking for the answer for this, and I got this idea from Sebastian's question. Somehow it works for me, maybe it will for those who encounter this issue.

I set a delegate to UIWebView and in the webViewDidFinishLoad, I detect if the webview has really finished loading by executing a Javascript.

- (void)webViewDidFinishLoad:(UIWebView *)webView {     if ([[webView stringByEvaluatingJavaScriptFromString:@"document.readyState"] isEqualToString:@"complete"]) {         // UIWebView object has fully loaded.     } } 
like image 50
Fedry Kemilau Avatar answered Sep 30 '22 14:09

Fedry Kemilau


My solution:

- (void)webViewDidFinishLoad:(UIWebView *)webView {     if (!webView.isLoading) {         // Tada     } } 
like image 39
tgf Avatar answered Sep 30 '22 15:09

tgf