Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 986
doxsi Avatar asked Apr 17 '13 17:04

doxsi


2 Answers

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];
like image 156
ararog Avatar answered Sep 20 '22 12:09

ararog


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

    _progressHUD = [MBProgressHUD showHUDAddedTo:self.view.window animated:YES];
like image 21
deepwinter Avatar answered Sep 17 '22 12:09

deepwinter