Pregunta

I tried this code to show MBProgressHUD but when I click on another tab and back to this tab, MBProgressHUD cannot hide. I tried this for 2 functions:

For 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];
});
}); 

for 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];
    });
    }); 

In first time, it runs ok. But after click on another tab and back, it cannot hide.

¿Fue útil?

Solución

Try making your MBProgressHUD a private property (strong, nonatomic). Then you can reference the same instance of your progress hud in other methods or threads and update or hide it.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top