0

これが私のコードです

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.mode = MBProgressHUDModeIndeterminate;
hud.labelText = @"Loading..";
dispatch_queue_t dispatchQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
dispatch_async(dispatchQueue, ^(void)
{
    [self information];
    [hud hide:YES];
});

しばらくするとメソッド情報が終了することがわかります。しかし、それが終了した後でも、プログレスバーは離れません。その理由は何ですか?

4

1 に答える 1

3

このようにしてください

MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
hud.mode = MBProgressHUDModeIndeterminate;
hud.labelText = @"Loading..";
dispatch_queue_t dispatchQueue = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0);
dispatch_async(dispatchQueue, ^(void)
{
[self information];
dispatch_sync(dispatch_get_main_queue(), ^{ 
[hud hide:YES];
});
}); 
于 2013-04-04T12:54:03.503 に答える