项目运行的时候弹出错误提示:The resource could not be loaded because the App transport security policy requires the use of a secure connection.
注:以下都是博客名三十六变的整理总结,链接:https://www.cnblogs.com/36bian/p/5237138.html,作为一名iOS小白,非常感谢各位的不吝分享;
- 原因:iOS9以后,苹果把原http协议改成了https协议,所以不能直接在http协议下GET/POST
- 解决方案一:
-
在Xcode中打开Info.plist文件,如下图,点击Infomation Property List右边的加号
https协议修改plist1.png
-
-
点击之后如下图,点击右边选择符号,选择App Transport Security Setting,如下图
https协议修改plist2.png
-
-
接着先将AppTransportSecuritySetting左边三角展开,然后点击右边的加号,再点击选择符号选择AllowArbitraryLoads
https协议修改plist3.png
-
-
最后将AllowArbitraryLoads的属性值改为YES,如图,就可以运行了;
https协议修改plist4.png
-
-
解决方案二:
直接编辑工程文件下的Info.plist文件,加入以下代码
修改Info.plist.png
网友评论