当 webview 完全加载时,我能够在 viewDidLoad 中成功显示 HUD 指示器,但无法在 webViewDidFinishLoad 方法中隐藏它。请帮忙。
我正在使用以下代码::
在 .h 文件中
MBProgressHUD *HUD;
在 viewDidLoad
- (void)viewDidLoad
{
[super viewDidLoad];
NSString *query = [[NSString alloc] initWithFormat:@"http://localhost/index.php?uid=%@", [[UIDevice currentDevice] uniqueIdentifier]];
NSURL *url = [[NSURL alloc] initWithString:query];
NSString *response = [[NSString alloc] initWithContentsOfURL:url];
if(response)
{
[webView loadRequest:[NSURLRequest requestWithURL:url]];
}
else
{
//NSLog(@"err %@",response);
}
HUD = [[MBProgressHUD showHUDAddedTo:self.view animated:YES] retain];
HUD.delegate = self;
HUD.labelText = @"loading";
}
并在 webViewDidFinishLoad
- (void)webViewDidFinishLoad:(UIWebView *)web
{
[HUD hide:TRUE]; //it does not work for me :(
}