swift2 - iOS 9 中的 WKWebView 问题

标签 swift2 ios9 wkwebview

我在使用 iOS 9 sdk 的 XCode 7 中使用 WKWebView 时遇到问题。由于某种原因,我尝试加载的网站有一半显示为空白(例如移动 Facebook)。

当我在 iOS 8 上构建应用程序时,WKWebView 工作得很好。我没有更改任何用于加载网页的代码(我使用了带有 nsurl 的 loadrequest),而且我知道 webview 是事件的,因为某些链接确实加载了。

这可能是一个错误吗?

最佳答案

这可能与 iOS 9 中引入的名为 ATS(应用程序传输安全)的新功能有关。

请参阅: https://developer.apple.com/library/prerelease/ios/technotes/App-Transport-Security-Technote/

All connections using the NSURLConnection, CFURL, or NSURLSession APIs use App Transport Security default behavior in apps built for iOS 9.0 or later, and OS X 10.11 or later. Connections that do not follow the requirements will fail.

可以添加异常(exception)或允许任何非安全连接。例如,您可以将其添加到 Info.plist:

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSAllowsArbitraryLoads</key>
  <true/>
</dict>

关于swift2 - iOS 9 中的 WKWebView 问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32669837/

相关文章:

audio - iOS9 中缺少 AVAssetExportSession 音频

swift - 如何检测 WKWebView 中的哈希变化?

ios - stringByAppendingPathComponent 不可用

ios - NSPredicate swift2 的最长时间

ios - 如何保持位置服务请求警报框一直出现

ios - 为不同屏幕制作 View Controller 的最佳方式

ios - App Transport Security 异常域是否可以在运行时修改?

ios - 崩溃 : WebThread

ios - 如何在可以沿此 webView 平移的 WKWebView 上添加 subview ?

swift - Swift 2.2 中 Alamofire 请求的返回值