2

我尝试显示此代码,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];
    });
    }); 

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

4

1 回答 1

1

尝试使您MBProgressHUD的私有财产(强,非原子)。然后,您可以在其他方法或线程中引用您的进度 hud 的相同实例并更新或隐藏它。

于 2013-10-14T07:13:59.343 回答