在使用自建https的证书用webview请求网页的时候无法返回数据,其主要原因是因为UIWebview无法解决URLSession的问题
在此使用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
}
}