码迷,mamicode.com
首页 > 移动开发 > 详细

iOS9—xcode7常见错误https问题解决

时间:2015-11-21 14:31:53      阅读:194      评论:0      收藏:0      [点我收藏+]

标签:

遇到的错误

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

少年莫慌,这是升级的ios9的https问题,解决起来很简单,关闭他,咱还是用http

解决

1:在Info.plist中添加NSAppTransportSecurity类型Dictionary。
2:在NSAppTransportSecurity下添加NSAllowsArbitraryLoads类型Boolean,值设为YES
3:注意,单元测试下面也有一个Info.plist,修改那个文件是没有作用的!

其他

如果想让有的域名支持https的话也可以这么配置:
补充了配置的方法
对于实在不支持HTTPS的应该首先考虑添加例外

添加例外的方式也很简单:
左键Info.plist选择open with source code
然后添加类似如下的配置:

    <key>NSAppTransportSecurity</key>
    <dict>
        <key>NSExceptionDomains</key>
        <dict>
            <key>qq.com</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
            </dict>
            <key>sina.com.cn</key>
            <dict>
                <key>NSIncludesSubdomains</key>
                <true/>
            </dict>
           </dict>
   </dict>

根据自己需要的域名修改, NSIncludeSubdomains 顾名思义是包括子域的意思。

iOS9—xcode7常见错误https问题解决

标签:

原文地址:http://blog.csdn.net/u013357243/article/details/49964149

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!