1

我有一个处理对 Web 服务的请求的类。当这开始从我创建的服务中获取信息并在另一个类视图上添加一个 HUD 时。像这样,

HUD = [[MBProgressHUD showHUDAddedTo:viewController.view animated:YES] retain];

加载完成后,我称之为,

[HUD hideHUDForView:viewController.view animated:YES];

我将代表设置为自我,

HUD.delegate = self;

但我无法将其从视图中删除。

- (void)hudWasHidden {
// Remove HUD from screen when the HUD was hidded
[HUD removeFromSuperview];
[HUD release];
HUD = nil;
}

我想从一个类开始在另一个类中显示,而第一个类是从 web 服务获取数据。然后将 i 从第一堂课中隐藏起来。

有任何想法吗?

编辑:

好的,现在我将第一堂课的代表设置为:

HUD.delegate = viewController;

但是我在哪里放:

- (void)hudWasHidden {
// Remove HUD from screen when the HUD was hidded
[HUD removeFromSuperview];
[HUD release];
HUD = nil;
}
4

2 回答 2

1

您可以通过将 HUD 的委托设置为其他类来做到这一点。

例如,如果我在 A 类中添加 HUD 并希望将其从 B 类中删除,那么我必须将 HUD 的委托设置为 B 类。

于 2011-08-26T11:53:11.277 回答
0

您可以在第一次调用时使用完成块,并在您从网络服务获得答案后继续工作,以将 HUD 隐藏在块中。

长的东西:

[self callServiceWithBlock:^(NSError *error){

//Your service has answered, you can now hide the HUD

    [hud HIDE:YES];
    if (error){
        NSLog(@"Error : %@");
    }


}];
于 2015-05-06T12:14:23.567 回答