问题场景: Xcode7.1网络访问失败,错误提示
The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.
问题描述:
因为iOS9引入了新特性App Transport Security (ATS)
。详情:App Transport Security (ATS)官方文档
新特性要求App内访问的网络必须使用HTTPS
协议。
但是大部分公司的项目目前使用的是HTTP
协议,使用私有加密方式保证数据安全。现在也没有马上改成HTTPS
协议传输。
解决方法:
1.在Info.plist中添加NSAppTransportSecurity
类型Dictionary
。
2.在NSAppTransportSecurity下添加NSAllowsArbitraryLoads类型Boolean,值设为YES