Webkit(swift)不会打开任何页面

时间:2017-03-26 22:26:59

标签: swift xcode macos

我无法打开项目中的所有页面,例如:

let url = NSURL (string: "http://www.dreambox.com");
    let requestObj = NSURLRequest(url: url! as URL);
    self.myWebView.mainFrame.load(requestObj as URLRequest!);

但我可以打开谷歌和维基百科这样的网站

let url = NSURL (string: "https://www.google.com");
    let requestObj = NSURLRequest(url: url! as URL);
    self.myWebView.mainFrame.load(requestObj as URLRequest!);

2 个答案:

答案 0 :(得分:2)

将此代码添加到您的Info.plist

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

答案 1 :(得分:0)

将这些密钥添加到Info.plist

enter image description here