此 Web 视图失败错误,即使在加载网站时也会显示警报弹出窗口。我相信我需要延迟此方法才能使其起作用。这样做的最佳方法是什么?
- (void)webView:(UIWebView *)webViewfail didFailLoadWithError:(NSError *)error
{
if([webViewfail isEqual:webview]) {
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Connection Failed" message:@"Check your Internet connection before refreshing."
delegate:webview
cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
}
这是我加载网站的方式
- (void)viewDidLoad
{
[webview loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.blabla.com"]]];
}