在使用自建https的證書(shū)用webview請(qǐng)求網(wǎng)頁(yè)的時(shí)候無(wú)法返回?cái)?shù)據(jù)桃犬,其主要原因是因?yàn)閁IWebview無(wú)法解決URLSession的問(wèn)題
在此使用WKWebview代替UIWebview鼠次,只需要在代理中做如下處理即可
extension ProtocolViewController :UIWebViewDelegate {
func webView(_ webView: UIWebView, shouldStartLoadWith request: URLRequest, navigationType: UIWebViewNavigationType) -> Bool {
currentRequest = request as NSURLRequest;
let configuration = URLSessionConfiguration()
currentSession = URLSession(configuration: configuration, delegate: self as URLSessionDelegate, delegateQueue: OperationQueue.main)
return true
}
}