我有一个 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];