执行下面代码

[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"的更多相关文章

  1. 解决NSURLConnection finished with error - code -1100错误

    更新到xcode9以后,拖进工程中一个html文件,webview加载这个文件,xcode一直抛出 NSURLConnection finished with error - code -1100异常 ...

  2. iOS - NSURLConnection finished with error - code -1002

    网络请求会异常,比如报错:Error domain: 在回调的地方打一个断点,然后用命令行查看下什么错误: po error 当错误是:**[Error Domain=NSURLErrorDomain ...

  3. ORA-00600: internal error code, arguments: [17281], [1001], [0x1FF863EE8], [], [], [], [], []

    我们生产服务器中的一个数据库发出监控告警日志的邮件,内容如下所示,在31号09:11分出现了大名鼎鼎的ORA-00600错误. Dear All: The Instance xxx' alert lo ...

  4. 删除数据报ORA-00600: internal error code, arguments: [ktbesc_plugged]

    Oracle在删除数据是以下错误: ORA-00600: internal error code, arguments: [ktbesc_plugged], [], [], [], [], [], [ ...

  5. jQuery ajax请求错误返回status 0和错误error的问题

    上周发现一个jQuery ajax请求错误返回status 0和错误error的问题,responseText是"error",状态码是0而不是200: $.ajax({ type ...

  6. IIS7.5 HTTP 错误500.19-Internal Server Error 无法访问请求的页面,因为该页的相关配置数据无效

    IIS7.5 HTTP 错误500.19-Internal Server Error 无法访问请求的页面,因为该页的相关配置数据无效 --------------------------------- ...

  7. MYSQL ERROR CODE 错误编号的意义

    mysql error code(备忘) 转1005:创建表失败 1006:创建数据库失败 1007:数据库已存在,创建数据库失败 1008:数据库不存在,删除数据库失败 1009:不能删除数据库文件 ...

  8. [Go] 如何正确地 抛出 错误 和 异常(error/panic/recover)?

    序言 错误 和 异常 是两个不同的概念,非常容易混淆.很多程序员习惯将一切非正常情况都看做错误,而不区分错误和异常,即使程序中可能有异常抛出,也将异常及时捕获并转换成错误.从表面上看,一切皆错误的思路 ...

  9. 服务器相关 HTTP 请求错误

    HTTP 400 - 请求无效 HTTP 401.1 - 未授权:登录失败 HTTP 401.2 - 未授权:服务器配置问题导致登录失败 HTTP 401.3 - ACL 禁止访问资源 HTTP 40 ...

随机推荐

  1. three dots in git

    What are the differences between double-dot “..” and triple-dot “…” in Git commit ranges? Using Comm ...

  2. 使用Python的PIL模块来进行图片对比

    使用Python的PIL模块来进行图片对比 在使用google或者baidu搜图的时候会发现有一个图片颜色选项,感觉非常有意思,有人可能会想这肯定是人为的去划分的,呵呵,有这种可能,但是估计人会累死, ...

  3. python学习笔记之入门

    1.变量 变量即为可以改变的量,值是可以更改的. 如何定义 name = ‘name’ age = 20 ..........  变量的定义规范 1.变量名只能是 字母.数字或下划线的任意组合 .2. ...

  4. Numpy基础之创建与属性

    import numpy as np ''' 1.数组的创建:np.array([]) 2.数组对象的类型:type() 3.数据类型:a.dtype 4.数组的型shape:(4,2,3) 5.定义 ...

  5. 设置xampp开机自动启动

    l  设置xampp开机自动启动: 1)vi /etc/init.d/xampp.sh 增加:#!/bin/sh     /opt/lampp/lampp start 2)vi /etc/rc.d/r ...

  6. vue 引入阿里图标

    1.去阿里图标矢量图标库将想要的图标添加入库 2.再去库中将图标添加到项目. 3.再到我的项目中,选择,我这里采用的是将图标代码包下载到本地再引入到vue项目中. 4.在vue项目的assets文件夹 ...

  7. pixi与lottie-web的benchmark测试

    生产版本 "dependencies": {     "lottie-web": "^5.5.7",     "pixi-spin ...

  8. 在Python中写入文件时,权限被拒绝错误

    我想创建一个文件并在python中写一些整数数据.例如,我有一个变量abc = 3,我试图将它写入一个文件(它不存在,我假设python将自己创建): fout = open("newfil ...

  9. [fw]awk求和

    suse11:~ # cat tmp.lst 4096 4 4096 4 4096 2 4096 4 8192 1 8192 4 8192 4 8192 4 8192 4 8192 4 8192 4 ...

  10. 淘汰赛制_NOI导刊2010提高(01)

    题目描述 淘汰赛制是一种极其残酷的比赛制度.2n名选手分别标号1,2,3,…,2^n-1,2^n,他们将要参加n轮的激烈角逐.每一轮中,将所有参加该轮的选手按标号从小到大排序后,第1位与第2位比赛,第 ...