开发者

WebView displaying text while loading

How can I display text "Loading..." or the 开发者_Python百科"spinner" while the user is waiting for the WebView to load and while it is still blank?

Thank You!


Sami's way is right.

- (void)webViewDidStartLoad:(UIWebView *)webView {
    NSLog (@"webViewDidStartLoad");
    [activityIndicator startAnimating];
}

- (void)webViewDidFinishLoad:(UIWebView *)webView {
    NSLog (@"webViewDidFinishLoad");
    [activityIndicator stopAnimating];
}


Take a look at the UIWebViewDelegate

You have two methods in the delegate that will be helpful to you:

- (void)webViewDidStartLoad:(UIWebView *)webView

- (void)webViewDidFinishLoad:(UIWebView *)webView

In the first method you can start the UIActivityIndicatorView, and in the second one stop it.


Add an UIActivityIndicatorView to your view in Interface Builder, connect it to your code and use the delegate methods Sami already pointed out to show/hide the UIActivityIndicatorView (that's the spinner you're talking about)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜