简体   繁体   中英

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?

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

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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM