I'm facing the issue with getting content Height of WebView by Whooshkaa playlist link https://player.whooshkaa.com/player/playlist/show/2321?sharing=true.
The WKWebView inside custom View and I'm gonna recalculate frame view after loading WebView success.
I've tried 3 ways:
- Create an observer when the webView contentSize changed like this Example.
- EvaluateJavaScript like this:
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
webView.evaluateJavaScript("document.body.offsetHeight") { [weak self] (height, _) in
guard let height = height as? CGFloat else { return }
// Still 200
}
}
---> But all the cases return offsetHeight only 200px. As you can see it's still missing the playlist content bellow.
Is there another way/trick that I can get offsetHeight correctly?