2

MBProgressHUDで少し問題が発生しました。Webビューがあり、データの読み込み中にHUDを表示したいと思います。HUDは表示されますが、数秒間しか表示されず、すでに消えていますが、Webビューの読み込みが完了していません。

-(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);}
4

2 に答える 2

5

showWhileExecutingメソッドを削除し、UIWebViewの以下のデリゲートメソッドでhudを非表示にすると、正常に機能します

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    [HUD hide:YES];
}
于 2012-03-15T11:12:29.670 に答える
1

WebビューをMBProgressViewHUDと統合したことはありません。これを使用する代わりに、ここでUIActivityIndi​​catorを使用し、WebViewのこのデリゲートで停止してresignFromSuperViewを実行する必要があります。

  • (void)webViewDidFinishLoad:(UIWebView *)webView

uはこのデリゲートでHUDを手動で非表示にできます:

 - (void)webViewDidFinishLoad:(UIWebView *)webView
{
   [HUD hide:YES];
   if(HUD!=nil)
   { 
       [HUD removeFromSuperview];
       [HUD release];
       HUD=nil;
   }
}
于 2012-03-15T11:11:20.373 に答える