Swift UIWebView not loading http sites(Swift UIWebView 不加载 http 网站)
问题描述
我创建了一个 Web 视图控制器,它加载 https 站点(例如:、)但不加载 http、非 ssl 安全站点(例如:http://bswd.us,http://www.barretthillins.com).当我在其中放置一个 hhtp 站点时,它确实会加载,但只是一个空白的白色 Web 视图.我需要如何解决这个问题?
I created a web view controller and it loads https sites(ex: , ) but not http, non ssl secured sites(ex: http://bswd.us, http://www.barretthillins.com). When i do put a hhtp site in there, it does load but just a blank, white web view. How would i need to fix this?
推荐答案
这是由于 Apple 在 WWDC 2015 上引入的新协议 App Transport Security.它不允许任何非 HTTPS 的连接代码>.您可以禁用它,但不建议这样做,因为它会保护您的应用.
This is due to the App Transport Security, a new protocol introduced by Apple at WWDC 2015. It doesn't allow any connections that are not HTTPS. You can disable it, however it's not recommended as it secures your app.
要禁用它,您必须编辑应用程序的 .plist.只需右键单击 .plist 文件并选择 Open As -> Source File 并添加以下代码:
To disable it you have to edit the App's .plist. Simply right-click the .plist file and select Open As -> Source File and add the following code:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key><true/>
</dict>
这将允许 HTTP 请求.
希望对您有所帮助,朱利安.
Hope that helps, Julian.
这篇关于Swift UIWebView 不加载 http 网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Swift UIWebView 不加载 http 网站
基础教程推荐
- iPhone - 获取给定地点/时区的当前日期和时间并将其与同一地点的另一个日期/时间进行比较的正确方法 2022-01-01
- Cocos2d iPhone 非矩形精灵触摸检测 2022-01-01
- iOS4 创建后台定时器 2022-01-01
- NSString intValue 不能用于检索电话号码 2022-01-01
- libGDX 从精灵或纹理中获取像素颜色 2022-01-01
- AdMob 广告未在模拟器中显示 2022-01-01
- navigator.geolocation.getCurrentPosition 在 Android 浏览器上 2022-01-01
- 如何从 logcat 中删除旧数据? 2022-01-01
- Android:getLastKnownLocation(LocationManager.NETWORK_PROVIDER 2022-01-01
- 通过重定向链接在 Google Play 中打开应用 2022-01-01
