ios - UIWebView 不断尝试加载但没有结果
<p><p>我正在尝试使用 UIWebView 连接到 wikiTravel 页面。这是我的代码:</p>
<pre><code>NSURL *url = ;
NSURLRequest *requestObj = ;
;
</code></pre>
<p>如果我将北京更改为康沃尔,它会很好地显示所有信息。如果我将北京更改为蒙特利尔,它只会加载 wikitravelLogo 和两个按钮,但它确实调用了 <code>webViewDidFinishLoad</code>。但是对于北京,它只是加载和加载,并没有显示任何内容。</p>
<p>每当调用 UIWebView 方法时,我都会打印到控制台,这是输出:</p>
<pre><code>2012-06-11 15:11:50.904 ExtraFeatures3 WEB VIEW DID START LOAD.
2012-06-11 15:11:57.607 ExtraFeatures3 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 WEB VIEW DID START LOAD.
2012-06-11 15:11:59.523 ExtraFeatures3 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 WEB VIEW DID START LOAD.
2012-06-11 15:12:00.875 ExtraFeatures3 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}
</code></pre>
<p>而且它一直在继续,一直在继续......我不知道该怎么办。</p>
<p><b>编辑</b>:我的所有搜索都让我找到了以下解决方法,我已经尝试过但没有开始工作:</p>
<pre><code>-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
if( == NSURLErrorCancelled)
{
return;
}
</code></pre>
<p>}</p>
<p>任何帮助将不胜感激!</p>
<p>谢谢!</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>根据本站:<a href="https://discussions.apple.com/thread/1727260?start=0&tstart=0" rel="noreferrer noopener nofollow">https://discussions.apple.com/thread/1727260?start=0&tstart=0</a> </p>
<p>这是解决方法:</p>
<pre><code>- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
NSLog(@"Error %i", error.code);
if (error.code == NSURLErrorCancelled) return; // this is Error -999
// error handling for "real" errors here
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - UIWebView 不断尝试加载但没有结果,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/10986265/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/10986265/
</a>
</p>
页:
[1]