您的位置:首页 > 移动开发

iOS知识---webView加载网址报错Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded beca

2016-06-29 18:26 393 查看
xcode在使用webView加载网页的时候可能会遇到加载不出来的报错问题,

App Transport Security has blocked a cleartext HTTP (http://)
resource load since it is insecure. Temporary exceptions can be configured via your app’s Info.plist file. 
2015-11-20 16:12:16.662 AFNetworking_(3.0)[3091:1742917] failure Error Domain=NSURLErrorDomain Code=-1022 “The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.”
UserInfo={NSUnderlyingError=0x7fedb8e02ef0 {Error Domain=kCFErrorDomainCFNetwork Code=-1022 “(null)”}, NSErrorFailingURLStringKey= http://www.baidu.com/  NSErrorFailingURLKey= http://www.baidu.com/ ,
NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.}

那是因为OS9让所有的HTTP默认使用了HTTPS,原来的HTTP协议传输都改成TLS1.2协议进行传输。直接造成的情况就是App发请求的时候弹出网络无法连接。解决方法,在工程里面的Info.plist里面添加如下节点: 
还有种新式该法 

App Transport Security Settings        Dictionary 
Allow Arbitrary Loads                         Boolean    Yes 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: