Alex Tau
Alex Tau

Reputation: 2639

How to show a loading message while UIWebView loads it's content?

I want to put a big spinner along with a "Loading message..." or a gif image, when UIWebView loads its contents so it won't just show a blank view. How should I do it?

Upvotes: 8

Views: 8070

Answers (2)

HungryArthur
HungryArthur

Reputation: 1087

Implement the UIWebView Delegate as outlined in Mihir's answer above but don't forget to assign the delegate otherwise the delegate methods will not be triggered

For example In ViewDidLoad you should add:

self.myWebView.delegate = self;

Upvotes: 2

Mihir Mehta
Mihir Mehta

Reputation: 13843

implement UIWebview's delegate method put this code in it

- (void)webViewDidStartLoad:(UIWebView *)webView {
    [activityIndicator startAnimating];
    myLabel.hidden = FALSE;
}

- (void)webViewDidFinishLoad:(UIWebView *)webView {
[activityIndicator stopAnimating];
myLabel.hidden = TRUE;
}

set ActivityIndicater's Hidden when stop property to TRUE

Upvotes: 20

Related Questions