In my controller, I have a call to WKWebViewInstance.loadRequest (url). If the Internet is not available, I want to upload an error message to WKWebView.
I found that
func webView(webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: NSError)
Called when WKWEbView navigation fails without an Internet connection. When I call the webView.loadHtmlString () call inside the above delegation method, nothing happens.
How to detect a lack of network connectivity while a WKWEbView navigation request is made, and instead load the corrected error message into the web view?
My delegate method code
func webView(webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: NSError) { webView.stopLoading() webView.loadHTMLString(Constants.OfflineHtmlString!,baseURL: nil) }
source share