2013-03-20 37 views
0

在一个堆栈中,我显示MBProgressHUD,如果通过使用其他堆栈时,某些计算称为我想要MBProgressHUD从视图中删除,但它没有从hud中删除..check我是什么错误做..MBProgressHUD视图不隐藏

称为LoginViewController.m

- (void)viewWillAppear:(BOOL)animated { 
    [super viewWillAppear:animated]; 

    [MBProgressHUD showHUDAddedTo:self.view animated:YES]; 
} 

-(void)myTask { 
    // Do something usefull in here instead of sleeping ... 

    [MBProgressHUD hideHUDForView:self.view animated:YES]; 

    [self.hud hide:YES]; 
    self.hud=nil; 
    [self.hud removeFromSuperview]; 

    //[self.hud showWhileExecuting:@selector(myTask1) onTarget:self withObject:nil animated:YES]; 
} 

现在ViewController得到电话,但鉴于将是相同的一个和

第一栈10

一些计算之后,我想在ViewController我想通过调用方法在LoginViewController ..check代码以删除从视图中HUD

- (void)didReceiveResponseFromServer:(NSString *)responseData 
{ 
    login=[[LoginViewController alloc]init]; 

    [self.login myTask]; 
} 
+0

可以请elabarote在哪里,你确切地想隐藏你的HUD层? – Dhruvik 2013-03-20 11:42:31

回答

1

设置UP MBProgressHUD

- (void) setupHUD 
{ 
    //setup progress hud 
    self.HUD = [[MBProgressHUD alloc] initWithFrame:self.window.bounds]; 
    [self.SpurView addSubview:self.HUD]; // add it as here. 
    self.HUD.dimBackground = YES; 
    self.HUD.minSize = CGSizeMake(150.f, 150.f); 
    self.HUD.delegate = self; 
    self.HUD.labelText = @"Loading..."; 
} 

然后使用如代码中所述,隐藏[self.HUD hide:YES];

0

像我一样, 我tyr [MBProgressHUD hideHUDForView:bAnimatedView animated:YES] 但它会在我快速推进和退出时无法工作。 所以我添加了一些东西来检查MBProgressHUD的视图。

MBProgressHUD *HUD = [MBProgressHUD HUDForView:bAnimatedView]; 
if (HUD!= nil) { 
    [HUD removeFromSuperview]; 
    HUD=nil; 
}