UIWebView 仅显示白屏 - Xcode 7

UIWebView giving only a white screen - Xcode 7

自从最近更新到Xcode7,我发现我的webView不会再加载了,只会显示白屏。

我已经搜索了解决方案,但无济于事。

我将 webView 连接编码如下:

class ViewController: UIViewController {

@IBOutlet weak var webviewInstance: UIWebView!

override func viewDidLoad() {
    super.viewDidLoad()

    // Connect UIWebView to the ordering page

    let url = NSURL (string: "http://www.google.com");
    let requestObj = NSURLRequest(URL: url!);
    webviewInstance.loadRequest(requestObj);
}

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
    // Dispose of any resources that can be recreated.
}


}

如有任何帮助,我将不胜感激。

前阵子我记得在这里读过一个关于 SO 的问题,说没有实施

- webView:shouldStartLoadWithRequest:navigationType: 

来自 UIWebViewDelegate 引起了问题。

如果那不能解决问题,您可以使用委托方法来调试您的问题

您必须检查应用 plist 文件并添加 AppTransportSecurity。 打开你的 plist 文件并添加它。搜索 AppTransportSecurity

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

如果您不在 PLIST 中添加 ATS,您的 link 就是 ignored/blocked。希望对您有所帮助