3

I have a WKWebView inside my UITableViewCell. I configure my webview with an HTML string as follows:

webView.loadHTMLString(myHTMLString, baseURL: URL(string: "http://www.myPage.com"))

I am expecting to receive the callback in the following delegate method once the webview has finished loading in order to calculate the content size of the webview.

 func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
            webView.evaluateJavaScript("document.readyState", completionHandler: { [weak self] (_, _) in
                guard let self = self else { return }
                webView.invalidateIntrinsicContentSize()
                self.delegate?.loadFinished()
            })
    }

It is taking too long to receive the callback in the above delegate.

Please suggest a way to optimise load time.

0 Answers0