I have a UIWebView
in my iPhone application where I am loading the website. Basically I am opening the mobile website in app. In website, there is media upload
functionality/ When user tries to upload photo(within mobile site), I am facing error is :-
NSURLErrorDomain error -999
The same web view(code) works fine with other URLs like www.apple.com and www.google.com.
NSURLRequest *request = [[NSURLRequest alloc]initWithURL:[NSURL URLWithString:self.urlToLoad]];
[webview loadRequest:request];
It doesnt seem to be a redirect issue. How to fix the error?
I am also getting the below warnings.
WF: _userSettingsForUser mobile: { filterBlacklist = ( ); filterWhitelist = ( ); restrictWeb = 1; useContentFilter = 0; useContentFilterOverrides = 0; whitelistEnabled = 0; }
Related error link:- https://discussions.apple.com/thread/1727260?start=0&tstart=0
This one is for WKWebView and Swift.
-999 is caused by ErrorCancelled. This means: another request is made before the previous request is completed. You can check it in this answer
In my scenario, I am checking the error code, if it is -999 then I just return from a function like following
func webView(_ webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: Error) {
if error.code == NSURLErrorCancelled {
return
}
//*** Your functionality ***
}
Note: Unlike NSError of Objective-C, 'code' property is not available with Swift Error. You handle it by creating enum as in this answer .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.