WebView loadRequest请求错误"NSURLConnection finished with error - code -1022"
执行下面代码
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.bing.com"]]];
webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error打印出来的的错误如下
[:] NSURLConnection finished with error - code -
[:] Error Domain=NSURLErrorDomain Code=- "The resource could not be loaded because the App Transport Security policy
requires the use of a secure connection." UserInfo={NSUnderlyingError=0x600000641f50
{Error Domain=kCFErrorDomainCFNetwork Code=- "The resource could not be loaded because the App Transport Security policy requires
the use of a secure connection." UserInfo={NSErrorFailingURLStringKey=http://www.bing.com/,
NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.,
NSErrorFailingURLKey=http://www.bing.com/}}, NSErrorFailingURLStringKey=http://www.bing.com/, NSErrorFailingURLKey=http://www.bing.com/,
NSLocalizedDescription=The resource could not be loaded because the App Transport Security policy requires the use of a secure connection.}
解决方案很简单:
URLString必须使用https的请求webview就能正常显示了
但后来发现要加载http://localhost:8080然后悲剧了,看来还是要研究一下具体机制了,在XCode 9就会出现错误中提示了很明显的信息
The resource could not be loaded because the App Transport Security policy
去百度一下ATS policy,就可以知道很详细的答案了,在SupportFiles->info.plist文件里面添加下面属性就好了,有直接的选项,不需要自己填写
done!
WebView loadRequest请求错误"NSURLConnection finished with error - code -1022"的更多相关文章
- 解决NSURLConnection finished with error - code -1100错误
更新到xcode9以后,拖进工程中一个html文件,webview加载这个文件,xcode一直抛出 NSURLConnection finished with error - code -1100异常 ...
- iOS - NSURLConnection finished with error - code -1002
网络请求会异常,比如报错:Error domain: 在回调的地方打一个断点,然后用命令行查看下什么错误: po error 当错误是:**[Error Domain=NSURLErrorDomain ...
- ORA-00600: internal error code, arguments: [17281], [1001], [0x1FF863EE8], [], [], [], [], []
我们生产服务器中的一个数据库发出监控告警日志的邮件,内容如下所示,在31号09:11分出现了大名鼎鼎的ORA-00600错误. Dear All: The Instance xxx' alert lo ...
- 删除数据报ORA-00600: internal error code, arguments: [ktbesc_plugged]
Oracle在删除数据是以下错误: ORA-00600: internal error code, arguments: [ktbesc_plugged], [], [], [], [], [], [ ...
- jQuery ajax请求错误返回status 0和错误error的问题
上周发现一个jQuery ajax请求错误返回status 0和错误error的问题,responseText是"error",状态码是0而不是200: $.ajax({ type ...
- IIS7.5 HTTP 错误500.19-Internal Server Error 无法访问请求的页面,因为该页的相关配置数据无效
IIS7.5 HTTP 错误500.19-Internal Server Error 无法访问请求的页面,因为该页的相关配置数据无效 --------------------------------- ...
- MYSQL ERROR CODE 错误编号的意义
mysql error code(备忘) 转1005:创建表失败 1006:创建数据库失败 1007:数据库已存在,创建数据库失败 1008:数据库不存在,删除数据库失败 1009:不能删除数据库文件 ...
- [Go] 如何正确地 抛出 错误 和 异常(error/panic/recover)?
序言 错误 和 异常 是两个不同的概念,非常容易混淆.很多程序员习惯将一切非正常情况都看做错误,而不区分错误和异常,即使程序中可能有异常抛出,也将异常及时捕获并转换成错误.从表面上看,一切皆错误的思路 ...
- 服务器相关 HTTP 请求错误
HTTP 400 - 请求无效 HTTP 401.1 - 未授权:登录失败 HTTP 401.2 - 未授权:服务器配置问题导致登录失败 HTTP 401.3 - ACL 禁止访问资源 HTTP 40 ...
随机推荐
- python改变导入模块中的变量的问题
Python中循环函数1调用函数2,函数2中import了一个模块,函数1: def run(): for a in b: runTest(a,patter) 函数2: def runTest(cas ...
- Note1
1.关于数据库主从备份与读写分离 主服务器数据库的每次操作都会记录在二进制日志文件mysql-bin.xxx中.从服务器的I/O线程使用专用帐号登陆到主服务器中读取该二进制文件,并将文件内容写入到自己 ...
- 返回闭包不能引用循环变量,请改写count()函数,让它正确返回能计算1x1、2x2、3x3的函数。
错误写法: 正确写法:
- day 109结算中心.
from django.db import models from django.contrib.contenttypes.fields import GenericForeignKey,Generi ...
- Windows重置网络命令
我们在日常使用电脑的时候会碰到网络异常,网络故障,想要针对性地去解决是很困难的. 有时候可能查遍了资料,花了大量时间,怎么搞都还是搞不定.所以,这次直接给大家分享一个通过重置网络来解决所有问题的方法. ...
- Linux系统ubuntu17安装jdk8并配置环境变量
上班多年,一直没有真正在Linux下开发过,没有捣鼓到Linux服务器,成为憾事.最近由于想学习Python,于是开始看书,学习Linux,学习shell编程. 选择Linux,先从最简单的ubunt ...
- angularJS 入门知识
模块:模块可以定义自己的控制器.服务.工厂类以及指令 模块可以依赖其他模块 模块两大常见错误: 定义模块的时候忘记第二个参数,变成使用模块而不是定义模块 使用模块的时候忘记引用依赖模块
- leetcode.双指针.680验证回文字符串-Java
1. 具体题目 给定一个非空字符串 s,最多删除一个字符.判断是否能成为回文字符串. 示例 1: 输入: "aba" 输出: True 示例 2: 输入: "abca&q ...
- Windows IIS PHP7 连接 SQLServer 2012
下载 php7 对 SQL Server 的扩展 https://www.microsoft.com/en-us/download/details.aspx?id=20098 下载后 安装到一个 目录 ...
- vue 实现active点击图片切换
循环条件下: 1.点击函数@click="active(index)" 获取点击的位置 2.讲索引值传给class,点击哪一个则显示哪一个的样式 3.在data添加ins的初始值 ...