I tried several methods to detect whether a UIWebView
did load every content from the source like this one and this one.
Here're some typical HTML string to be loaded with UIWebView:
<p>some string</p>
<p><img alt="" src="/path/image.png" /></p>
...something like above
The below method is always firing too soon before all content (not only the text) that I couldn't get the correct height of the UIWebView
. (height is shorter than what the webView actually is)
func webViewDidFinishLoad(webView: UIWebView) {
// tried to get the content height
if webView.stringByEvaluatingJavaScriptFromString("document.readyState") == "complete" {
let height = webView.stringByEvaluatingJavaScriptFromString("document.body.offsetHeight")!
}
}
Where could I get the correct height of the content?