Search code examples
iphoneiosmbprogresshud

MBProgressHUD not stopping


Here's my code

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 information];
    [hud hide:YES];
});

I know that method information finishes after a while. But even after it is finished the progress bar is not moving away. What could be the reason?


Solution

  • Do it like this

    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 information];
    dispatch_sync(dispatch_get_main_queue(), ^{ 
    [hud hide:YES];
    });
    });