2013-04-17 186 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];