- (void)webViewDidStartLoad:(UIWebView *)webView
{
// starting the load, show the activity indicator in the status bar
[UIApplication sharedApplication].networkActivityIndicatorVisible = YES;
}
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
// finished loading, hide the activity indicator in the status bar
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
// load error, hide the activity indicator in the status bar
[UIApplication sharedApplication].networkActivityIndicatorVisible = NO;
// report the error inside the webview
NSString* errorString = [NSString stringWithFormat:
@"<html><center><font size=+5 color='red'>An error occurred:<br>%@</font></center></html>",
error.localizedDescription];
[myWebView loadHTMLString:errorString baseURL:nil];
}
本文来自优快云博客,转载请标明出处:http://blog.youkuaiyun.com/bruni/archive/2010/10/29/5974729.aspx
本文介绍如何在iOS应用中使用UIWebView进行网页加载时显示活动指示器,并在加载完成或出现错误时隐藏指示器及展示错误信息。
278

被折叠的 条评论
为什么被折叠?



