UIWebView 无法加载(错误 -999)
UIWebView won't load(Error -999)
当我开始加载我的 UIWebView 时,它给我这个错误:
2015-06-12 10:24:08.768 App[7034:692175] Error Domain=NSURLErrorDomain Code=-999 "The operation couldn’t be completed. (NSURLErrorDomain error -999.)" UserInfo=0x165f3950 {NSErrorFailingURLKey=https://google.com/, NSErrorFailingURLStringKey=https://google.com/}
而且它从未完成加载。奇怪的是:当我在模拟器上执行它时,它工作得很好。另外,当我手动重新加载 webview 时,它也能正常工作。
因此这意味着 URL 并且它的参数很好(https://google.com/ 不是实际的 URL)。
在网上我找到了这个解决方法:
if([error code] == NSURLErrorCancelled){
return;
}else{
//Actual error handling
}
这确实被调用了,但没有解决问题
编辑:
_
webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.infoView.frame.size.width, self.infoView.frame.size.height)];
[self.infoView addSubview:_webView];
[_webView setHidden:YES];
_webView.scalesPageToFit = YES;
_webView.delegate = self;
_webView.scrollView.scrollEnabled = NO;
_webView.scrollView.bounces = NO;
[_webView setUserInteractionEnabled:YES];
[_webView addSubview:invisView];
[_webView loadRequest:[self getRequest]];
这似乎是 iOS HTTPS 请求中的错误。我的解决方法是在出现错误时重做请求。第二次请求似乎加载正常,现在运行良好。
当我开始加载我的 UIWebView 时,它给我这个错误:
2015-06-12 10:24:08.768 App[7034:692175] Error Domain=NSURLErrorDomain Code=-999 "The operation couldn’t be completed. (NSURLErrorDomain error -999.)" UserInfo=0x165f3950 {NSErrorFailingURLKey=https://google.com/, NSErrorFailingURLStringKey=https://google.com/}
而且它从未完成加载。奇怪的是:当我在模拟器上执行它时,它工作得很好。另外,当我手动重新加载 webview 时,它也能正常工作。
因此这意味着 URL 并且它的参数很好(https://google.com/ 不是实际的 URL)。
在网上我找到了这个解决方法:
if([error code] == NSURLErrorCancelled){
return;
}else{
//Actual error handling
}
这确实被调用了,但没有解决问题
编辑: _
webView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, self.infoView.frame.size.width, self.infoView.frame.size.height)];
[self.infoView addSubview:_webView];
[_webView setHidden:YES];
_webView.scalesPageToFit = YES;
_webView.delegate = self;
_webView.scrollView.scrollEnabled = NO;
_webView.scrollView.bounces = NO;
[_webView setUserInteractionEnabled:YES];
[_webView addSubview:invisView];
[_webView loadRequest:[self getRequest]];
这似乎是 iOS HTTPS 请求中的错误。我的解决方法是在出现错误时重做请求。第二次请求似乎加载正常,现在运行良好。