MBProgressHUD* saveImghud = [[MBProgressHUD alloc] init];
saveImghud.labelText = @"正在保存";
saveImghud.mode = MBProgressHUDModeIndeterminate;
[self.view addSubview:saveImghud];[saveImghud show:YES];
//异步请求
[NSURLConnection sendAsynchronousRequest:request queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *connectionError){
NSInteger responseCode = [(NSHTTPURLResponse *)response statusCode];
if (responseCode == 200) {
NSString *returnString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
if (returnString) {
[self saveImage:returnString];
}
}
else
{
//通知主线程刷新
dispatch_async(dispatch_get_main_queue(), ^{
saveImghud.mode = MBProgressHUDModeText;
saveImghud.labelText = @"保存失败";
[saveImghud hide:YES afterDelay:1.7];
});
}
}];