WKWebView 未加载 url

WKWebView is not loading url

WKWebview 未加载某些 url。这是我的代码片段

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

当我将 url 更改为 URL(string: "https://www.ndtv.com/") 时,它起作用了。不确定为什么?任何建议都会很有帮助。

首先检查您是否在 info.plist 文件中设置了权限?如果不是,那么您只需要在 info.plist 文件

中获得 TransportSecuritYES 许可
<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

喜欢下面

Mac 应用开发者

如果您正在为 Mac 构建应用程序,请确保在您的目标中打开 App Sandbox ON 并勾选 Networks Incoming/Outgoing 连接。


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

<key>com.apple.security.app-sandbox</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>