Categories
ios swift uiwebview webview wkwebview

webViewDidFinishLoad in WKWebView

I have to migrate from UIWebView to WKWebView and I’m having some trouble with this. It looks like that “WKWebView” has no member ‘request’. Is there a way to handle this situation using the WKWebView? I simply need to get the URL loaded and then if it contains “.pdf” just show a button.

func webViewDidFinishLoad(_ webView : WKWebView) {
UIApplication.shared.isNetworkActivityIndicatorVisible = false
if (webView.request?.url!.absoluteString)!.range(of: ".pdf") != nil {
pdfBackButton.isHidden = false
}
else {
pdfBackButton.isHidden = true}
}