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 サービスからのデータのロード中に誰かが画面の残りの部分に触れた場合は閉じたいと思います。どんな助けでも大歓迎です。