我在 ViewController 中使用 ASINetWorkQueue。所以,在队列执行期间,我想显示一个 MBProgressHUD。
- (void) addItemsToEndOfTableView{
NSLog(@"add items");
[[self networkQueue] cancelAllOperations];
// Création d'une nouvelle file (queue) de requetes
[self setNetworkQueue:[ASINetworkQueue queue]];
[[self networkQueue] setDelegate:self];
[[self networkQueue] setRequestDidFinishSelector:@selector(requestFinished:)];
[[self networkQueue] setRequestDidFailSelector:@selector(requestFailed:)];
[[self networkQueue] setQueueDidFinishSelector:@selector(queueFinished:)];
...add requests
HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];
[self.navigationController.view addSubview:HUD];
HUD.dimBackground = YES;
HUD.delegate = self;
[HUD showWhileExecuting:@selector(stopHub) onTarget:self withObject:nil animated:YES];
}
[[self networkQueue] go];
所以,当 queueFinished 被调用时,我想停止 hud:
- (void)queueFinished:(ASINetworkQueue *)queue
{
[self stophud];
}
-(void)stophud
{
[MBProgressHUD hideHUDForView:self.view animated:YES];
}
但实际上,进度 Hud 很快消失了,而 iphone 顶部栏中的活动指示器在收集数据时正在运行。
那么,怎么了?