I would like to know when my WebView has finished loading a page. Im quite new to this and I wonder if you have any suggestions. I need to create a “Loading screen” while the page is loading. This is my basic code:
- (void)viewDidLoad {
NSString *urlAddress = @"http://google.se";
//Create a URL object.
NSURL *url = [NSURL URLWithString:urlAddress];
//URL Requst Object
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
//Load the request in the UIWebView.
[webView loadRequest:requestObj];
}
Thanks!
There are two different callbacks when the view finishes loading, successful load and failed load. They are both part of the the UIWebViewDelegate protocol.
Implement it and set yourself as the delegate for your web view. Then implement
to know when the loading has finished, so that you can remove your loading screen, and implement
to know if it failed so that you can show and appropriate message to the user instead of an infinite loading screen.