Ios WKWebView发布请求Swift 5
我正在尝试使用下面的代码在WKWebview中打开带有一些post参数的URLIos WKWebView发布请求Swift 5,ios,swift,wkwebview,swift5,nsurlrequest,Ios,Swift,Wkwebview,Swift5,Nsurlrequest,我正在尝试使用下面的代码在WKWebview中打开带有一些post参数的URL //let postdata = strPostString.data(using: .utf8) var request = URLRequest(url: URL(string:posturl)!) request.httpMethod = "POST" let bodyData = "data1=\(String(describing: strPos
//let postdata = strPostString.data(using: .utf8)
var request = URLRequest(url: URL(string:posturl)!)
request.httpMethod = "POST"
let bodyData = "data1=\(String(describing: strPostString))"
request.httpBody = bodyData.data(using: .utf8)!
request.addValue("application/x-www-form-urlencoded", forHTTPHeaderField: "Content-Type")
jioPGWebV.navigationDelegate = self
jioPGWebV.load(request)
但无法加载页面
始终在委托方法中获取nil httpbody
func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) {
print(navigationAction.request.httpBody)
decisionHandler(.allow)
}
请帮忙