我想隐藏MBProgressHUD,当我从服务器接收XML响应并且我使用httpconnection从服务器获取XML,有人帮助我吗?
请
按照以下步骤隐藏 ProgressHUD
采用 HUD 的类级别变量
MBProgressHUD *hud;
然后制作两个函数
-(void)showProgress
{
if (!hud)
hud = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:hud];
//hud.delegate = self;
hud.labelText = @"Loading...";
[hud show:YES];
}
-(void)hideProgress
{
[hud hide:YES];
[hud removeFromSuperview];
[hud release];
hud=nil;
}
在发起网络命中时调用 showProgress()并在调用成功或失败的回调时调用 hideProgress()。
您应该在类或从服务器获取数据的委托中保留 MBProgressHUD 的实例,
在界面中
{
MBProgressHUD *hud;
}
- 当进度开始时执行 [HUD 显示..] 并
- [HUD隐藏]当它完成时。
我想你用HUD delgete来隐藏
试试这个:-
-(void)hudWasHidden // for remove the hud
{
[HUD removeFromSuperview];
}
呼叫 Hud
HUD = [[MBProgressHUD alloc] initWithView:self.view];
HUD.graceTime = .1;
HUD.navigationBar = self.navigationController.navigationBar;
HUD.labelFont = [UIFont fontWithName:@"Arial" size:14];
HUD.delegate = self;
[self.view addSubview:HUD];
[HUD showWhileExecuting:@selector(yourFunction name:) onTarget:self withObject:nil animated:YES];
在 .h 文件中使用此
MBProgressHUD *HUD;