UITableView headings shown on top of MBProgressHUD UITableView headings shown on top of MBProgressHUD ios ios

UITableView headings shown on top of MBProgressHUD

My solution was pretty simple. Instead of using self's view, I used self's navigationController's view.

HUD = [[MBProgressHUD alloc] initWithView:self.navigationController.view];[self.navigationController.view addSubview:HUD];

This should work for the OP because his picture shows he's using a UINavigationController. If you don't have a UINavigationController, you might add another view on top of your UITableView, and add the HUD to that. You'll have to write a little extra code to hide/show this extra view.

An unfortunate thing with this simple solution (not counting my idea adding another view mentioned above) means the user can't use the navigation controls while the HUD is showing. For my app, it's not a problem. But if you have a long running operation and the user might want to press Cancel, this will not be a good solution.

It's probably because self.view is a UITableView, which may dynamically add/remove subviews including the headers, which could end up on top of the HUD after you add it as a subview. You should either add the HUD directly to the window, or (for a little more work but perhaps a better result) you could implement a UIViewController subclass which has a plain view containing both the table view and the HUD view. That way you could put the HUD completely on top of the table view.

My solution was:

self.appDelegate = (kmAppDelegate *)[[UIApplication sharedApplication] delegate];.._progressHUD = [[MBProgressHUD alloc] initWithView:self.appDelegate.window];.[self.appDelegate.window addSubview:_progressHUD];

Works like a charm for all scenarios involving the UITableViewController. I hope this helps someone else. Happy Programming :)