8

我在导航项中有一个按钮,它的动作是 BUTTON_ACTION。通过按下它,MBProgressHUD 被激活并且动作起作用。但是使屏幕“隐藏”的“dimBackground”在导航栏上不起作用,并且可以在 MBProgressHUD 期间再次按下该按钮。代码是:

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

我尝试使用:

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

有什么想法吗?提前致谢。

4

2 回答 2

16

要使 MBProgressHUD 显示在包括 UINavigationBar 在内的所有 UI 控件上方,您必须执行以下操作:

 HUD = [[MBProgressHUD alloc] initWithWindow:self.view.window];
 [self.view.window addSubview:HUD];
于 2013-04-17T17:11:27.647 回答
1

@ararog 是对的,但做起来也很简单

    _progressHUD = [MBProgressHUD showHUDAddedTo:self.view.window animated:YES];
于 2014-06-28T12:46:58.170 回答