我尝试使用此代码显示MBProgressHUD,但是当我单击另一个选项卡并返回此选项卡时,MBProgressHUD无法隐藏。我尝试了2个功能:

对于updatearray()

 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 updatearray];
dispatch_sync(dispatch_get_main_queue(), ^{
[hud hide:YES];
});
});

用于getVideolist()
 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 getVideolist];
    dispatch_sync(dispatch_get_main_queue(), ^{
    [hud hide:YES];
    });
    });

第一次,它运行正常。但是单击另一个选项卡并返回后,它无法隐藏。

最佳答案

尝试将MBProgressHUD设置为 private 属性(强,非原子性)。然后,您可以在其他方法或线程中引用进度平视的同一实例,并对其进行更新或隐藏。

关于ios - 无法在iOS中隐藏MBProgressHUD,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/19353381/

10-10 20:33