WKWebview insdie UITableviewcell with dynamic height

Hello,

I have used WKWebview inside my tableview cell and given constraint inside my xib file.

I am loading html text in webview which i get from server side in api and i have taken webview height constraint property for update height on did finish delegate method.

It's not working proper and not giving proper height and on scroll every-time it's rendering with different height.

My requirement is i want to display math equations and html content on webview with dynamic height of cell.

I have done research and tried everything but it's not working.

I am using below code for update webview height.

func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {     webView.evaluateJavaScript("document.readyState", completionHandler: { (ready, error) in       if ready != nil {         DispatchQueue.main.asyncAfter(deadline: .now()) {           webView.evaluateJavaScript("document.body.scrollHeight") { [weak self] (result, _) in             guard let self = self, let result = result as? Double else { return }             self.webViewHeightConstraint.constant = CGFloat(result)             self.webView.updateConstraints()            }         }       }     })   }    

Please help me to solve this issue.

Thank you