- (void) didClickDone{
if (isValide ==0) {
(...)
[newFormDataRequest setDelegate:self];
[newFormDataRequest startAsynchronous];
(...)
//show the label
[self showWithLabel];
}
}
# pragma mark - AsiHTTPRequest delegate methods
- (void)requestFinished:(ASIHTTPRequest *)request
{
NSLog(@"PostAdRequest = %@", [request responseString]);
HUD.customView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"37x-Checkmark.png"]] autorelease];
HUD.mode = MBProgressHUDModeCustomView;
HUD.labelText = @"Completed";
sleep(10);
[self hudWasHidden];
[self dismissModalViewControllerAnimated:YES];
}
我正在尝试在AsiHTTPRequest的肯定回答后更改MBPrograssHub。但观点仍然相同。你知道为什么吗?
由于
答案 0 :(得分:2)
因为sleep(10)
不允许UIThread更新HUD。
- (void)requestFinished:(ASIHTTPRequest *)request {
NSLog(@"PostAdRequest = %@", [request responseString]);
HUD.customView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"37x-Checkmark.png"]] autorelease];
HUD.mode = MBProgressHUDModeCustomView;
HUD.labelText = @"Completed";
[self performSelector:@selector(removeHUD) withObject:nil afterDelay:10.0f];
}
- (void) removeHUD {
[self hudWasHidden];
[self dismissModalViewControllerAnimated:YES];
}