2013-02-19 73 views

回答

0

我不確定SVProgressHUD的實現是什麼,但我在當前的應用程序中使用了一個名爲MBProgressHUD的類似工具。希望這個建議仍然適用。

如果我正確理解你的問題,你想知道如何解僱你的progressHUD如果AFNetworking調用失敗?如果這是你的問題,那麼你所需要做的就是在你的失敗區中關閉你的HUD,如下所示。

MBProgressHUD *HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view]; 
[navigationController.view addSubview:HUD]; 

HUD.dimBackground = YES; 
[HUD show:YES]; 

//Set up the request 
NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"example.com"]]; 
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL:url]; 

[request setHTTPMethod:@"POST"]; 

//Set up the operation 
AFHTTPRequestOperation *operation = [[AFHTTPRequestOperation alloc] initWithRequest:request]; 

[operation setCompletionBlockWithSuccess:^(AFHTTPRequestOperation *operation, id responseObject) { 

     // Hide activity indicator after success 
     [HUD show:NO]; 
     [HUD hide:YES]; 

} failure:^(AFHTTPRequestOperation *operation, NSError *error) { 

    // Hide activity indicator after failure 
    [HUD show:NO]; 
    [HUD hide:YES]; 
}]; 

// Fire off the operation 
[operation start];