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 网站


基础教程推荐
- :hover 状态不会在 iOS 上结束 2022-01-01
- 如何使用 YouTube API V3? 2022-01-01
- 固定小数的Android Money Input 2022-01-01
- “让"到底是怎么回事?关键字在 Swift 中的作用? 2022-01-01
- 在 iOS 上默认是 char 签名还是 unsigned? 2022-01-01
- Android ViewPager:在 ViewPager 中更新屏幕外但缓存的片段 2022-01-01
- LocationClient 与 LocationManager 2022-01-01
- 如何使 UINavigationBar 背景透明? 2022-01-01
- 使用 Ryzen 处理器同时运行 WSL2 和 Android Studio 2022-01-01
- Android文本颜色不会改变颜色 2022-01-01