【发布时间】:2013-10-28 19:31:33
【问题描述】:
我有一个 viewDidLoad,它创建一个 web 视图并启动一个活动指示器。如何使活动指示器仅在网页出现时停止?如何在活动指示器中添加诸如“正在加载”之类的词?
// Create the UIWebView
UIWebView *webView = [[UIWebView alloc] initWithFrame:self.view.bounds];
[self.view addSubview:webView];
// Start the throbber to check if the user exists
UIActivityIndicatorView *activityView=[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
activityView.center = CGPointMake([self screenWidth] / 2.0, 370.0);
[activityView startAnimating];
activityView.tag = 100;
[self.view addSubview:activityView];
NSString* url = @"http://google.com";
NSURL* nsUrl = [NSURL URLWithString:url];
NSURLRequest* request = [NSURLRequest requestWithURL:nsUrl cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:30];
// Remove activity view
UIView *viewToRemove = [self.view viewWithTag:100];
//[viewToRemove removeFromSuperview];
[webView loadRequest:request];
【问题讨论】:
-
在下面查看我的答案
标签: ios uiwebview ios7 uiactivityindicatorview