문제

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.

도움이 되었습니까?

해결책

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];

다른 팁

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

    _progressHUD = [MBProgressHUD showHUDAddedTo:self.view.window animated:YES];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top