Xcode7 网络请求报错:The resource could not be loaded because the App Transport Security policy...

在使用Xcode7进行iOS应用开发时,遇到WebView加载URL因App Transport Security(ATS)策略导致的错误。ATS是iOS9引入的安全特性,限制了HTTP连接。解决方法是在Info.plist文件中添加NSAppTransportSecurity字典,并设置NSAllowsArbitraryLoads为YES,允许不安全的网络请求。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天在学习IOS的WebView控件时发现WebView加载URL报错,菜鸟的我只能上Google一查究竟。

错误信息:

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

最后网上查到在IOS9的时候引入了App Transport Security (ATS)。

详细文档参考:https://developer.apple.com/library/prerelease/ios/releasenotes/General/WhatsNewIniOS/Articles/iOS9.html#//apple_ref/doc/uid/TP40016198-DontLinkElementID_13




解决办法:

第一步:在Info.plist中添加NSAppTransportSecurity类型Dictionary

第二步:在NSAppTransportSecurity下添加NSAllowsArbitraryLoads类型Boolean,值为YES




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值