简体   繁体   English

使用UIWebView的NSURLErrorDomain错误-999

[英]NSURLErrorDomain error -999 using UIWebView

I have a UIWebView in my iPhone application where I am loading the website. 我在加载网站的iPhone应用程序中有一个UIWebView 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 :- 在网站上,有media upload功能/当用户尝试上传照片(在移动网站内)时,我面临的错误是:

NSURLErrorDomain error -999 NSURLErrorDomain错误-999

The same web view(code) works fine with other URLs like www.apple.com and www.google.com. 相同的网络视图(代码)可以与其他网址(例如www.apple.com和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 = ( ); WF:_userSettingsForUser移动电话:{filterBlacklist =(); filterWhitelist = ( ); filterWhitelist =(); restrictWeb = 1; strictWeb = 1; useContentFilter = 0; useContentFilter = 0; useContentFilterOverrides = 0; useContentFilterOverrides = 0; whitelistEnabled = 0; whitelistEnabled = 0; } }

Related error link:- https://discussions.apple.com/thread/1727260?start=0&tstart=0 相关错误链接: -https : //discussions.apple.com/thread/1727260?start=0&tstart=0

This one is for WKWebView and Swift. 这是针对WKWebView和Swift的。

-999 is caused by ErrorCancelled. -999是由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 在我的情况下,我正在检查错误代码,如果它是-999,那么我只是从如下函数返回

  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. 注意:与Objective-C的NSError不同,Swift Error不提供'code'属性。 You handle it by creating enum as in this answer . 您可以按照此答案通过创建枚举来处理它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM