doxsi
doxsi

Reputation: 1024

MBProgressHud does not work on navigation bar

I have a buttono in the navigation item which action is BUTTON_ACTION. By pressing it, MBProgressHUD is activate and the action work. but the "dimBackground" that make "hidden" the scrren, doe not work on the navigationbar, and the button can be pressed again during the MBProgressHUD. The code is:

  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 tryed to use:

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

Any idea about that? thanks in advance.

Upvotes: 8

Views: 2202

Answers (2)

deepwinter
deepwinter

Reputation: 4678

@ararog is right, but it's also simple to just do

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

Upvotes: 1

ararog
ararog

Reputation: 1092

To make the MBProgressHUD being displayed above all UI controls including the UINavigationBar you must do this:

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

Upvotes: 16

Related Questions