MBProgressHUD出了点小问题。我有一个网页视图,并希望在数据加载时显示HUD。HUD出现了,但只停留了几秒钟,并且已经消失了,但是webview并没有完成加载。
-(void)viewDidAppear:(BOOL)animated{
// Should be initialized with the windows frame so the HUD disables all user input by covering the entire screen
HUD = [[MBProgressHUD alloc] initWithWindow:[UIApplication sharedApplication].keyWindow];
// Add HUD to screen
[self.view.window addSubview:HUD];
// Regisete for HUD callbacks so we can remove it from the window at the right time
HUD.delegate = self;
HUD.labelText = @"Loading";
HUD.detailsLabelText = @"updating data";
// Show the HUD while the provided method executes in a new thread
[HUD showWhileExecuting:@selector(loadingWebView) onTarget:self withObject:nil animated:YES];}
- (void) loadingWebView {
NSString *fullURL = beverageViewString;
NSURL *url = [NSURL URLWithString:fullURL];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[beverageView loadRequest:requestObj];
NSLog(@"%@",beverageViewString);}发布于 2012-03-15 19:12:30
删除showWhileExecuting方法并将hud隐藏在UIWebView的下面的委托方法中,然后它就可以正常工作了
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
[HUD hide:YES];
}发布于 2012-03-15 19:11:20
我们从未将web视图与MBProgressView HUD集成在一起,而不是使用这个,您应该在这里使用UIActivityIndicator,并在webView的这个代理处停止& resignFromSuperView:
您可以在此代理中手动隐藏HUD:
- (void)webViewDidFinishLoad:(UIWebView *)webView
{
[HUD hide:YES];
if(HUD!=nil)
{
[HUD removeFromSuperview];
[HUD release];
HUD=nil;
}
}https://stackoverflow.com/questions/9718401
复制相似问题