2

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.

7
  • Did the [self updatearray]; finish loading ? Commented Oct 14, 2013 at 4:11
  • @ShivanRaptor: Yes, it finish loading. I've been updated my question. Pls check out. thanks Commented Oct 14, 2013 at 4:13
  • handle exception if there any error. if there any see what is it. Commented Oct 14, 2013 at 4:15
  • It does not have error. I don't know why it can not hide. Commented Oct 14, 2013 at 4:24
  • how you sure about that . have you put try catch block to check it? Commented Oct 14, 2013 at 4:26

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.