2013-04-17 94 views
7

我在导航项中有一个按钮,其操作是BUTTON_ACTION。按下它,MBProgressHUD被激活并且动作起作用。但是“隐藏”字体的“dimBackground”,在导航栏上不起作用,并且可以在MBProgressHUD中再次按下该按钮。 的代码是: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; 
    [email protected]"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]; 

我tryed使用方法:

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

想过这事?提前致谢。

+1

的Xcode?为什么?使用不同的IDE会有什么不同? – 2013-04-17 17:04:47

回答

15

为了使MBProgressHUD上面包括UINavigationBar的必须这样做的所有UI控件显示:

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

是的!非常感谢! – doxsi

1

@ararog是正确的,但它也简单,只是做

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