WKWebView未加载网址

use*_*722 13 macos ios swift wkwebview

WKWebview没有加载某些网址.这是我的代码片段

let myURL = URL(string: "https://contents.tdscpc.gov.in/")
let myRequest = URLRequest(url: myURL!)
webView.load(myRequest)
Run Code Online (Sandbox Code Playgroud)

当我改变网址说它URL(string: "https://www.ndtv.com/")有效.不知道为什么?任何建议都会非常有帮助.

iPa*_*tel 23

首先检查你是否在info.plist文件中设置了权限?如果没有,那么你只需要采取的许可TransportSecuritYESinfo.plist文件

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>
Run Code Online (Sandbox Code Playgroud)

如下

在此输入图像描述


Mic*_*ick 6

Mac App开发人员

如果要为Mac开发应用程序,请确保上交App Sandbox ON目标并勾选“ Networks传入/传出连接”。

在此处输入图片说明


更新:如果您更喜欢长途旅行,请将以下内容添加到 YourAppName.entitlements

<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
Run Code Online (Sandbox Code Playgroud)