我正在尝试使用 UIWebView 连接到 wikiTravel 页面。这是我的代码:
NSURL *url = [NSURL URLWithString:@"http://wikitravel.org/en/Beijing"];
NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
[wikiWebView loadRequest:requestObj];
如果我将北京更改为康沃尔,它会很好地显示所有信息。如果我将北京更改为蒙特利尔,它只会加载 wikitravel 徽标和两个按钮,但确实会调用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)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
if([error code] == NSURLErrorCancelled)
{
return;
}
}
任何帮助将不胜感激!
谢谢!