Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transp...

调试加载 WebView 链接地址的时候抛出了如下异常:

异常原因:

Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transport Security policy requires the use of a secure connection."

简单从字面意思来看是因为无法加载资源,因为应用程序传输安全策略要求使用安全连接。即 iOS9 之后 http 协议变为 https 协议的安全问题。

解决办法:

将工程下的 Info.plist 文件添加如下 code:

NSAppTransportSecurity

    NSAllowsArbitraryLoads
    

添加如上配置属性后,再次编译工程,即可。


以上便是此次分享的内容,希望内容能对大家实际有所帮助,有什么不足之处欢迎指点共同进步!

你可能感兴趣的:(Error Domain=NSURLErrorDomain Code=-1022 "The resource could not be loaded because the App Transp...)