gpt4 book ai didi

iphone - MBProgressHUD UIWebView

转载 作者:行者123 更新时间:2023-12-03 20:28:09 25 4
gpt4 key购买 nike

MBProgressHUD 遇到了一点问题。我有一个 WebView ,想要在加载数据时显示 HUD。HUD 出现,但只停留了几秒钟,然后就消失了,但 Web View 尚未完成加载。

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

最佳答案

在 UIWebView 的下面的委托(delegate)方法中删除 showWhileExecuting 方法并隐藏 hud 即可正常工作

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
[HUD hide:YES];
}

关于iphone - MBProgressHUD UIWebView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9718401/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com