解决iOS9新特性无法使用http的解决方法

在使用Xcode7,iOS9编译应用时会出现这样的问题,
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内访问的网络必须使用HTTPS协议。

在Info.plist中添加NSAppTransportSecurity类型Dictionary。
在NSAppTransportSecurity下添加NSAllowsArbitraryLoads类型Boolean,值设为YES

如下图:

这里写图片描述

你可能感兴趣的:(ios)