代码之家  ›  专栏  ›  技术社区  ›  doxsi

MBProgressHud在导航栏上不起作用

  •  8
  • doxsi  · 技术社区  · 12 年前

    我在导航项中有一个按钮,其操作为BUTTON_action。按下此按钮,MBProgressHUD即被激活,该动作开始工作。但使scrren“隐藏”的“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];
    

    你知道吗?提前谢谢。

    2 回复  |  直到 12 年前
        1
  •  16
  •   ararog    12 年前

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

     HUD = [[MBProgressHUD alloc] initWithWindow:self.view.window];
     [self.view.window addSubview:HUD];
    
        2
  •  1
  •   deepwinter    10 年前

    @ararog是对的,但也很简单

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