The easiest way to do this is to add this line after creating your UIWebView.
[webView setDelegate:self]
Now you will call webViewDidFinishLoad: and the whole method should look like this.
- (void)webViewDidFinishLoad:(UIWebView *)webView { [[UIApplication sharedApplication] setNetworkActivityIndicatorVisible:NO]; }
I will explain this further, because in the future you will need to understand the delegation.
UIWebView is just an object that displays web data. Actually, I donβt really like it when I need to process all this, because he really just loves web data. Now, in your case, you wanted to know when the UIWebView was done, doing your favorite little task. To do this, your UIWebView gives him a scream like "Yo Holmes, now I load this data, so do whatever you do now." and your UIWebView continues to have fun.
So what we did, we told UIWebView that its delegate, in this case, was our current class by setting the delgate property in the webView for ourselves.
From there, you can call any of the methods available to the UIWebView delegate (all of which are in the documentation) and force them to perform tasks secondary to the main purpose of the UIWebView.
Make sense?
source share