我尝试使用此代码显示 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)属性(强、非原子)。然后,您可以在其他方法或线程中引用您的进度 hud 的相同实例并更新或隐藏它。
关于ios - 无法在 iOS 中隐藏 MBProgressHUD,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19353381/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |