There are situations where it’s convenient to hide the WKWebView until the load request is completed. Here’s how you can do it.

Hide the WKWebView when you trigger the load request

videoView.isHidden = true
    videoView.load(req)

 

Conform your class to WKNavigationDelegate to get these two methods where you can detect that the load request is either completed or failed.

func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
    videoView.isHidden = false
}

func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error) {
    videoView.isHidden = false
}

Leave a Comment

Your email address will not be published.