iOS:有人知道为什么我收到999错误,即使页面加载了吗?

时间:2013-12-26 08:01:53

标签: ios objective-c uiwebview uiwebviewdelegate nsurlsession

我将NSLogs添加到我的所有UIWebView委托方法和viewDidLoad以跟踪所有内容,由于某种原因,我看到一个999错误,以及多个“DidFinishLoad”调用。有谁知道如何优化这个?

这是我的日志:

2013-12-25 23:56:51.656 VA[10598:60b] View Did Load
2013-12-25 23:56:52.216 VA[10598:60b] Should Start Load with request.
2013-12-25 23:56:52.219 VA[10598:60b] Webview did start load.
2013-12-25 23:56:53.531 VA[10598:60b] Should Start Load with request.
2013-12-25 23:56:53.536 VA[10598:60b] failed with error. Error Domain=NSURLErrorDomain Code=-999 "The operation couldn’t be completed. (NSURLErrorDomain error -999.)" UserInfo=0x16e4e240 {NSErrorFailingURLKey=http://myexamplesite.com/us/en_us, NSErrorFailingURLStringKey=http://myexamplesite.com/us/en_us}
2013-12-25 23:56:53.549 VA[10598:60b] Webview did start load.
2013-12-25 23:56:54.259 VA[10598:60b] Should Start Load with request.
2013-12-25 23:56:54.260 VA[10598:60b] Webview did start load.
2013-12-25 23:56:54.263 VA[10598:60b] Webview Did Finish Load
2013-12-25 23:56:54.266 VA[10598:60b] Should Start Load with request.
2013-12-25 23:56:54.267 VA[10598:60b] Webview did start load.
2013-12-25 23:56:54.269 VA[10598:60b] Webview Did Finish Load
2013-12-25 23:56:54.293 VA[10598:60b] Should Start Load with request.
2013-12-25 23:56:54.294 VA[10598:60b] Webview did start load.
2013-12-25 23:56:54.300 VA[10598:60b] Should Start Load with request.
2013-12-25 23:56:54.301 VA[10598:60b] Webview did start load.
2013-12-25 23:56:54.402 VA[10598:60b] Should Start Load with request.
2013-12-25 23:56:54.403 VA[10598:60b] Webview did start load.
2013-12-25 23:56:54.405 VA[10598:60b] Webview Did Finish Load
2013-12-25 23:56:54.509 VA[10598:60b] Should Start Load with request.
2013-12-25 23:56:54.510 VA[10598:60b] Webview did start load.
2013-12-25 23:56:54.653 VA[10598:60b] Webview Did Finish Load
2013-12-25 23:56:54.861 VA[10598:60b] Webview Did Finish Load
2013-12-25 23:56:54.914 VA[10598:60b] Webview Did Finish Load
2013-12-25 23:56:54.921 VA[10598:60b] Webview Did Finish Load

以下是我在viewDidLoad中加载webView的方法:

NSURL *url = [NSURL URLWithString:shoeLink];
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];
    [shoeWebView loadRequest:requestObj];

我可以通过哪种方式对其进行优化,以便获得最快的加载时间吗?谢谢,节日快乐!

1 个答案:

答案 0 :(得分:2)

为加载的网页的每个帧调用shouldStart,didStart和didFinish的UIWebView委托回调方法。这就是为什么你会看到这些调用对于某些网页重复这么多次的原因。正如您从日志中可以看出的那样,加载其中一个框架的某些操作失败了,但其余部分加载正常,这就是您仍然能够看到该网页的原因。

关于问题的第二部分,没有真正的优化可以使这一切更快地发生,你已经以正确的方式提出了请求。