1

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

4

3 に答える 3

2

これを試してもらえますか

UIAlertView を表示した後、View Controller (またはウィンドウ) にビューを追加し、新しい空の UIView を全画面サイズで表示します。UITapGestureRecognizer を使用してこのビューにアタッチします

UITapGestureRecognizer *singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleSingleTap:)];
[view addGestureRecognizer:singleTap];
[singleTap release];

-(void)handleSingleTap:(UITapGestureRecognizer *)sender{
    [myAlert dismissWithClickedButtonIndex:0 animated:YES];
    [view removeFromSuperView];
}
于 2013-11-09T12:57:39.650 に答える
0

次のUIResponderメソッドの下でそれを行うことができます -(void)touchesBeganまたは -(void)touchesEnded

その中を無効にUIActivityIndicatorします。

于 2013-11-09T12:51:40.043 に答える
0

使用touchesEnded方法

タッチ終了メソッド内で、停止と削除の機能を実行しますUIActivityIndicatorView

-(void)touchesEnded

{

[indicator stopAnimating];

[indicator removeFromSuperView];

}
于 2013-11-09T12:57:17.607 に答える