我在加载一些网页时使用 MBProgressHUD 显示微调器。
对于某些网站,它工作得很好,但是当试图打开一个“twitter”帐户页面时,微调器仍在屏幕上,这意味着 web 视图还没有完成加载..
这是我的代码,适用于 twitter 以外的其他网站:
- (void)webViewDidStartLoad:(UIWebView *)web
{
MBProgressHUD *HUD = [MBProgressHUD showHUDAddedTo:self.view animated:YES];
HUD.labelText = @"Loading..";
}
- (void)webViewDidFinishLoad:(UIWebView *)web
{
[MBProgressHUD hideHUDForView:self.view animated:YES];
}
并在 ViewDidLoad :
NSURL *urlAddress = [NSURL URLWithString: @"https://twitter.com/#!/Applicaphone"];
NSURLRequest *requestObject = [NSURLRequest requestWithURL:urlAddress];
[webView loadRequest:requestObject];