In my application, I need to get the webpage height in WKWebView. Therefore, I use the code below.
webView.evaluateJavaScript(("document.height"), completionHandler: { contentHeight,error in
print(contentHeight)
})
Prior to iOS 9, this will return the height of the webpage correctly. But in iOS 10 contentHeightalways nil.
I have installed
webView.scrollView.scrollEnabled = false
and the web view is in UITableViewCell.
Height webViewand UITableViewCellare variable. There is an upper and lower restriction on the web view to match the cell.
When I get the height of the webpage, I want it to be reflected in the height of the cell.
source
share