MBProgressHUD 对另一个类隐藏
我有一个处理网络服务请求的类。当它开始从服务获取信息时,我创建并在另一个类视图上添加 HUD。像这样,
HUD = [[MBProgressHUD showHUDAddedTo:viewController.view animated:YES] retain];
当加载完成时,我调用它,
[HUD hideHUDForView:viewController.view animated:YES];
我将委托设置为 self,
HUD.delegate = self;
但我无法将其从视图中删除。
- (void)hudWasHidden {
// Remove HUD from screen when the HUD was hidded
[HUD removeFromSuperview];
[HUD release];
HUD = nil;
}
我想从一个类开始,然后在另一个类上显示,而第一个类是从网络服务获取数据。然后把我从第一堂课中隐藏起来。
有什么想法吗?
编辑:
好的,现在我将第一类中的委托设置为:
HUD.delegate = viewController;
但是我该放在哪里:
- (void)hudWasHidden {
// Remove HUD from screen when the HUD was hidded
[HUD removeFromSuperview];
[HUD release];
HUD = nil;
}
I have a class that handles request to a webservice. When this start to fetch information from the service I create and add a HUD on another class view. Like this,
HUD = [[MBProgressHUD showHUDAddedTo:viewController.view animated:YES] retain];
When the loading is finished I call this,
[HUD hideHUDForView:viewController.view animated:YES];
I set the delegate to self,
HUD.delegate = self;
But I can not get it to remove from the view.
- (void)hudWasHidden {
// Remove HUD from screen when the HUD was hidded
[HUD removeFromSuperview];
[HUD release];
HUD = nil;
}
I want to start in one class to show on another while the first is fetching data from the webservice. Then hide i from the first class.
Any ideas?
EDIT:
OK now I set the delegate in the first class to:
HUD.delegate = viewController;
But where do I put:
- (void)hudWasHidden {
// Remove HUD from screen when the HUD was hidded
[HUD removeFromSuperview];
[HUD release];
HUD = nil;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以通过将 HUD 的委托设置为其他类来做到这一点。
例如,如果我在 A 类中添加 HUD,并希望将其从 B 类中删除,那么我必须将 HUD 委托设置为 B 类。
You can do this by setting the delegate of your HUD to other class.
For example if i add the HUD in Class A and want to remove it from Class B then i have to set delegate of HUD to class B.
您可以使用第一次调用中的完成块,并在从网络服务获得答案后继续工作,以将 HUD 隐藏在块中。
长长的一行:
You could use a completion block from your first call and work your way up once you got an answer from the webservice, to hide the HUD in the block.
Something long the lines of :