iOS 9 中的 WKWebView 问题
WKWebView problems in iOS 9
我在 XCode 7 中使用 iOS 9 sdk 时遇到 WKWebView 问题。出于某种原因,我尝试加载的网站有一半是空白的(例如移动 Facebook)。
当我在 iOS 上构建我的应用程序时,WKWebView 工作得很好 8. 我没有更改任何加载网页的代码(我使用带有 nsurl 的 loadrequest),而且我知道 webviews 是活动的因为某些链接会加载。
这可能是错误吗?
这可能与 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.
可以添加例外或允许任何不安全的连接。例如,您可以将此添加到您的 Info.plist:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
我在 XCode 7 中使用 iOS 9 sdk 时遇到 WKWebView 问题。出于某种原因,我尝试加载的网站有一半是空白的(例如移动 Facebook)。
当我在 iOS 上构建我的应用程序时,WKWebView 工作得很好 8. 我没有更改任何加载网页的代码(我使用带有 nsurl 的 loadrequest),而且我知道 webviews 是活动的因为某些链接会加载。
这可能是错误吗?
这可能与 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.
可以添加例外或允许任何不安全的连接。例如,您可以将此添加到您的 Info.plist:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>