Documents from Apple Inc.:
Nsurlerrorcancelled (-999)
"When asynchronous load cancellation is returned. The WEB Toolkit Framework delegate receives this error when it performs a cancel operation on the load resource. Note that nsurlconnection or nsurldownload delegates do not receive this error if the download is canceled. "
Therefore, the most likely scenario for this scenario is for you to load the request, and then load the other (or the same) before the first completion. This can happen, for example, if a call to loadRequest
(or loadHTMLString
) Such a method viewDidAppear:
can be called multiple times, or a quick return to the last viewed page; Quick click on the 2 link inUIWebView ...都会造成这样的问题出现。
The simplest way is to:
-(void) WebView: (UIWebView *) WebView didfailloadwitherror: (Nserror *) error{ // NSLog (@ "%@", error); if ([error code]! = nsurlerrorcancelled) { // give error prompt }}
The general recommendation is to review how well where you call loadRequest
(or loadHTMLString
) and possibly provide some code.
To troubleshoot this problem, I recommend adding the following traces to your Web view delegate:
- (void) Webviewdidstartload: (UIWebView *) WebView {NSLog (@"starting to download request:%@", [WebView.request.URL absolutestring]);}- (void) Webviewdidfinishload: (UIWebView *) WebView {NSLog (@"finished downloading request:%@", [WebView.request.URL absolutestring]);}- (void) WebView: (UIWebView *) WebView didfailloadwitherror: (Nserror *) Error {if([error code] = =nsurlerrorcancelled) NSLog (@"Canceled Request:%@", [WebView.request.URL absolutestring]);}
If you check the output, you should see more clearly what's going on.
How does I fix Nsurlerrordomain error-999 in IPhone 3.0 OS