本文介绍了iOS9和uiwebview问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的webview可以在ios9以后的版本上正常工作,但是似乎不能在ios9上工作,它显示了一个空白页面,但URL已通过.

I have webview working fine for version less then ios9, but seems not working for ios9, and its shows me a blank page, but the url is passed.

推荐答案

要配置每个域的异常,以便您的应用可以连接到非安全(或未启用TLSv1.2的安全主机),请添加以下密钥到您的Info.plist中(请注意,从第一个Xcode 7 beta种子开始,Xcode当前不会自动完成这些键):

To configure a per-domain exception so that your app can connect to a non-secure (or non TLSv1.2-enabled secure host), add these keys to your Info.plist (and note that Xcode doesn’t currently auto-complete these keys as of the first Xcode 7 beta seed):

<key>NSAppTransportSecurity</key>
<dict>
  <key>NSExceptionDomains</key>
  <dict>
    <key>yourserver.com</key>
    <dict>
      <!--Include to allow subdomains-->
      <key>NSIncludesSubdomains</key>
      <true/>
      <!--Include to allow HTTP requests-->
      <key>NSTemporaryExceptionAllowsInsecureHTTPLoads</key>
      <true/>
      <!--Include to specify minimum TLS version-->
      <key>NSTemporaryExceptionMinimumTLSVersion</key>
      <string>TLSv1.1</string>
    </dict>
  </dict>
</dict>

您还可以使用其他密钥来配置App Transport Security,例如:

There are other keys that you can use to configure App Transport Security as well, such as:

NSRequiresCertificateTransparency
NSTemporaryExceptionRequiresForwardSecrecy
NSTemporaryThirdPartyExceptionAllowsInsecureHTTPLoads
NSTemporaryThirdPartyExceptionMinimumTLSVersion
NSTemporaryThirdPartyExceptionRequiresForwardSecrecy

对于演示,您可以如下图所示进行操作:

For Demostration you can do like that as shown in following image:

但是,如果我不知道我需要使用的所有不安全域怎么办?

如果您的应用程序(例如第三方网络浏览器)需要加载任意内容,Apple提供了一种完全禁用ATS的方法,但是我怀疑您明智地使用此功能是明智的:

If your app (a third-party web browser, for instance) needs to load arbitrary content, Apple provides a way to disable ATS altogether, but I suspect it’s wise for you to use this capability sparingly:

<key>NSAppTransportSecurity</key>
<dict>
  <!--Include to allow all connections (DANGER)-->
  <key>NSAllowsArbitraryLoads</key>
      <true/>
</dict>

您可以在此处

这篇关于iOS9和uiwebview问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 14:18