In my app, I need to get the height of a webpage in a WKWebView
. So I use the code below.
webView.evaluateJavaScript(("document.height"), completionHandler: { contentHeight,error in
print(contentHeight)
})
Until iOS 9, this returns the webpage height correctly. But in iOS 10, contentHeight
is always nil
.
I've set
webView.scrollView.scrollEnabled = false
and the web view is in a UITableViewCell
.
The height of webView
and of the UITableViewCell
are variable. There's a top and bottom constraint on the web view to fit to the cell.
When I get the webpage height, I want it to be reflected in the cell's height.