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.
[self updatearray];finish loading ?