MBProgressHud does not work in navigation bar

I have a button in a navigation element whose action is BUTTON_ACTION. By clicking on it, MBProgressHUD and the action are activated. but "dimBackground", which "hide" the violins, do not work on the navigation bar, and the button can be pressed again during MBProgressHUD. The code:

HUD = [[MBProgressHUD alloc] initWithView:self.view]; [self.view addSubview:HUD]; // Regiser for HUD callbacks so we can remove it from the window at the right time HUD.delegate = self; HUD.labelText=@ "Buscando Bares..."; HUD.dimBackground = YES; // Show the HUD while the provided method executes in a new thread [HUD showWhileExecuting:@selector(BUTTON_ACTION) onTarget:self withObject:nil animated:YES]; 

I tried using:

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

Any ideas on this? thanks in advance.

+7
source share
2 answers

To make MBProgressHUD displayed above all user interface controls, including the UINavigationBar, you must do this:

  HUD = [[MBProgressHUD alloc] initWithWindow:self.view.window]; [self.view.window addSubview:HUD]; 
+15
source

@ararog is right, but also just do

  _progressHUD = [MBProgressHUD showHUDAddedTo:self.view.window animated:YES]; 
+1
source

All Articles