vzm
vzm

Reputation: 2450

How to add a loading image while UIWebView is loaded?

In the main view of my app, I have a button that segue's to another view that has a UIWebView. Usually, it takes about 2-3 seconds to load.. During this awkward loading time, how can a loading image be added and animated?

Example: enter image description here

Upvotes: 0

Views: 455

Answers (1)

Gabriele Petronella
Gabriele Petronella

Reputation: 108111

You can show/hide a HUD - like SVProgressHUD or MBProgressHUD - withing the UIWebViewDelegate methods.

Set your controller as a delegate and implement, for instance, the two methods

- (void)webViewDidStartLoad:(UIWebView *)webView {
    [SVProgressHUD showWithStatus:@"Loading..."];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    [SVProgressHUD dismiss];
}

Upvotes: 3

Related Questions