Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect when a UIWebView has completely finished loading?

I am trying to build a filter for a UIWebView and I am struggiling to detect when the UIWebView has completely finished loading. I have used the following two methods

– webView:shouldStartLoadWithRequest:navigationType:
– webViewDidFinishLoad:

but the issue is that these will be called multiple times when a page has frames and additional content to load.

What I need is to know when the view has completely loaded and there is no more content to fetch. Then when the content has loaded I can check to URL of the page against a list of approved URLS.

ANy ideas?

like image 897
ORStudios Avatar asked Aug 22 '14 11:08

ORStudios


1 Answers

Use the UIWebViewDelegate protocol method webViewDidFinishLoad and webView's isLoading property

 - (void)webViewDidFinishLoad:(UIWebView *)webView
 {
    //Check here if still webview is loding the content
    if (webView.isLoading)
       return;

    //after code when webview finishes
    NSLog(@"Webview loding finished");
 }
like image 51
Paresh Navadiya Avatar answered Sep 19 '22 07:09

Paresh Navadiya