无法获取HTTP的图片资源

2020-01-10  本文已影响0人  杨帅iOS

项目中加载微信的头像为http的开头的图片资源.
xcode报错

The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.

在info.plist文件中添加

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSExceptionDomains</key>
    <dict>
        <key>yourdomain.com</key>
        <dict>
            <key>NSExceptionAllowInsecureHTTPLoads</key>
            <true/>
            <key>NSExceptionRequiresForwardSecrecy</key>
            <true/>
            <key>NSIncludesSubdomains</key>
            <true/>
            <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
            <true/>
        </dict>
    </dict>
    <key>NSAllowsArbitraryLoadsInWebContent</key>
    <true/>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>
    <key>yourdomain.com</key> //输入图片的域名即可
上一篇 下一篇

猜你喜欢

热点阅读