I am using a table view and trying to show MBProgressHud for cell selections that take a long time to present a modal (2.5 seconds).
Here is how I am starting MBProgressHud:
- (void)showProgressHud
{
dispatch_async(dispatch_get_main_queue(), ^{
[MBProgressHUD showHUDAddedTo:self.streamTableView animated:YES];
});
}
- (void)hideProgressHud
{
dispatch_async(dispatch_get_main_queue(), ^{
[MBProgressHUD hideHUDForView:self.streamTableView animated:YES];
});
}
I have noticed that the progress HUD shows only when the network activity indicator is not spinning.
The network becomes active when the table is being reloaded (using Restkit 0.20.0). I have AFNetworking configured to start the activity indicator when there is an open connection.
I have verified that if I disable the activity indicator the problem does not go away:
[[AFNetworkActivityIndicatorManager sharedManager] setEnabled:NO];
I'd really like to be able to keep the option enabled either way. Any suggestions?
It looks like the network activity indicator was tying up the run loop that MBProgressHud uses.
I ended up using this technique to allow the MBProgressHud time to show before the indicator ties up the loop again.
- (void)showProgressHud
{
dispatch_async(dispatch_get_main_queue(), ^{
[MBProgressHUD showHUDAddedTo:self.streamTableView animated:YES];
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate distantPast]];
});
}