简体   繁体   English

UIWebView仅提供白屏-Xcode 7

[英]UIWebView giving only a white screen - Xcode 7

Since the recent update to Xcode 7, I have found that my webView will no longer load, it will only show a white screen. 自从Xcode 7最近更新以来,我发现我的webView将不再加载,它将仅显示白屏。

I have searched for a solution, to no avail. 我一直在寻找解决方案,但无济于事。

I have coded the webView connection as follows: 我已将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.
}


}

I would greatly appreciate any help with this. 我将不胜感激与此有关的任何帮助。

A while back I remember reading a question here on SO saying that not implementing 前阵子我记得在这里读过一个问题,说没有实现

- webView:shouldStartLoadWithRequest:navigationType: 

from UIWebViewDelegate was causing problems. UIWebViewDelegate引起问题。

If that don't solve the issue, you can use the delegate methods to debug your problem 如果这样不能解决问题,则可以使用委托方法来调试问题

You have to check the app plist file and add the AppTransportSecurity. 您必须检查应用程序plist文件并添加AppTransportSecurity。 Open your plist file and add this. 打开您的plist文件并添加它。 Search for AppTransportSecurity 搜索AppTransportSecurity

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

If you don't add the ATS in your PLIST your link are ignored/blocked. 如果您未在PLIST中添加ATS,则您的链接将被忽略/阻止。 I hope this can help you 希望对您有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM