我正在从 Web 服务中获取数据,在数据获取期间,我UIAcitivityIndicatorView
在屏幕上显示一个。该指标在UIAlertView
UIAlertView *waitAlert = [[UIAlertView alloc] initWithTitle:@"Please Wait...." message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil];
[waitAlert show];
indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
// Adjust the indicator so it is up a few pixels from the bottom of the alert
indicator.center = CGPointMake(waitAlert.bounds.size.width / 2, waitAlert.bounds.size.height - 50);
[waitAlert addSubview:indicator];
NSURL *url = [NSURL URLWithString:URLString];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
[NSThread detachNewThreadSelector:@selector(startAnimation) toTarget:self withObject:self.view];
[NSURLConnection sendAsynchronousRequest:urlRequest queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
{
// Data to populate the tableview
[[NSOperationQueue mainQueue] addOperationWithBlock:^ {
[self.tableView1 reloadData];
//Stop the UIActivitiyIndicatorView
[self stopLoading];
}];
}];
当数据成功加载时,我可以成功关闭它,但UIActivityIndicatorView
如果有人在从 Web 服务加载数据期间触摸屏幕的其余部分,我想关闭它。任何帮助将不胜感激。