我正在尝试使用 UIWebView 连接到 wikiTravel 页面。这是我的代码:
NSURL *url = [NSURL URLWithString"http://wikitravel.org/en/Beijing"];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[wikiWebView loadRequest:requestObj];
如果我将北京更改为康沃尔,它会很好地显示所有信息。如果我将北京更改为蒙特利尔,它只会加载 wikitravel Logo 和两个按钮,但它确实调用了 webViewDidFinishLoad 。但是对于北京,它只是加载和加载,并没有显示任何内容。
每当调用 UIWebView 方法时,我都会打印到控制台,这是输出:
2012-06-11 15:11:50.904 ExtraFeatures3[893:307] WEB VIEW DID START LOAD.
2012-06-11 15:11:57.607 ExtraFeatures3[893:307] WEB VIEW FAILED TO LOAD: Error Domain=NSURLErrorDomain Code=-999 "The operation couldn’t be completed. (NSURLErrorDomain error -999.)" UserInfo=0x19be10 {NSErrorFailingURLKey=http://wikitravel.org/en/Beijing, NSErrorFailingURLStringKey=http://wikitravel.org/en/Beijing}
2012-06-11 15:11:57.619 ExtraFeatures3[893:307] WEB VIEW DID START LOAD.
2012-06-11 15:11:59.523 ExtraFeatures3[893:307] WEB VIEW FAILED TO LOAD: Error Domain=NSURLErrorDomain Code=-999 "The operation couldn’t be completed. (NSURLErrorDomain error -999.)" UserInfo=0x1a3190 {NSErrorFailingURLKey=http://wikitravel.org/en/Beijing, NSErrorFailingURLStringKey=http://wikitravel.org/en/Beijing}
2012-06-11 15:11:59.534 ExtraFeatures3[893:307] WEB VIEW DID START LOAD.
2012-06-11 15:12:00.875 ExtraFeatures3[893:307] WEB VIEW FAILED TO LOAD: Error Domain=NSURLErrorDomain Code=-999 "The operation couldn’t be completed. (NSURLErrorDomain error -999.)" UserInfo=0x1a6e00 {NSErrorFailingURLKey=http://wikitravel.org/en/Beijing, NSErrorFailingURLStringKey=http://wikitravel.org/en/Beijing}
而且它一直在继续,一直在继续......我不知道该怎么办。
编辑:我的所有搜索都让我找到了以下解决方法,我已经尝试过但没有开始工作:
-(void)webViewUIWebView *)webView didFailLoadWithErrorNSError *)error
{
if([error code] == NSURLErrorCancelled)
{
return;
}
}
任何帮助将不胜感激!
谢谢!
Best Answer-推荐答案 strong>
根据本站:https://discussions.apple.com/thread/1727260?start=0&tstart=0
这是解决方法:
- (void)webViewUIWebView *)webView didFailLoadWithErrorNSError *)error
{
NSLog(@"Error %i", error.code);
if (error.code == NSURLErrorCancelled) return; // this is Error -999
// error handling for "real" errors here
}
关于ios - UIWebView 不断尝试加载但没有结果,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/10986265/
|