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 ...
随机推荐
- element-ui中的loading的实际应用
实际开发中,要如何指定loading在我们想要的区域加遮罩呢? 前提: 你已经引入element-ui,如下: import ElementUI from 'element-ui' import { ...
- sonarqube6.7.1使用
1.插件安装 方法1.登入sonarqube-web安装 admin/admin 配置--应用市场--全部 英文片:administration--configuration--marketplace ...
- Spring-Boot"原生态"的logback
前言 Logback是由 log4j创始人设计的又一个开源日志组件: logback当前分成三个模块: logback-core logbackclassic logback-access logba ...
- IDEA默认快捷键
idea常用快捷键大全 Idea常用快捷键大全,拿小本本记下来,忘记了可以方便查找.编写代码Ctrl+Shift + Enter,语句完成“!”,否定完成,输入表达式时按 “!”键Ctrl+E,最 ...
- AST7D08 心率计
接线: 1.GND 2.+3.3V 3.RST 4. 5.CS 6.READY 7.DI 8.DO 9.CLK
- 用其他音乐源帮帮网易云,Ubuntu听歌利器
镜像文章 1.用其他音乐源帮帮网易云,Android听歌利器 2.用其他音乐源帮帮网易云,Windows听歌利器 众所周知,国内只有网易云推出了Linux的客户端,在Listen 1并不十分好用的基础 ...
- [Java] 缓存池
new Integer(123) 与 Integer.valueOf(123) 的区别在于: new Integer(123) 每次都会新建一个对象: Integer.valueOf(123) 会使用 ...
- this.$router.push相关的vue-router的导航方法
this.$router.push相关的vue-router的导航方法:https://blog.csdn.net/zeroyulong/article/details/80312750
- 如何取消bootstrap浮动时的padding值
在bootstrap框架中使用浮动时,可以对元素添加pull-left 或 pull-right 类来达到目的.但是框架会默认给该元素添加一个15px的左右padding. <div class ...
- python学习第二天--字符串及格式化输出
# 字符串# 字符串取值:字符串名[索引值] 只能取单个值# 正序访问,从0开始str1 = "hello world"print(str1[3]) # 输出"l&quo ...