iOS10 WKWebview - evaluateJavaScript("document.height") return nil
<p>In my app, I need to get the height of a webpage in a <code>WKWebView</code>. So I use the code below.</p>

<pre><code>webView.evaluateJavaScript(("document.height"), completionHandler: { contentHeight,error in
    print(contentHeight)
})
</code></pre>

<p>Until iOS 9, this returns the webpage height correctly. But in iOS 10, <code>contentHeight</code> is always <code>nil</code>.</p>

<p>I've set</p>

<pre><code>webView.scrollView.scrollEnabled = false
</code></pre>

<p>and the web view is in a <code>UITableViewCell</code>. </p>

<p>The height of <code>webView</code> and of the <code>UITableViewCell</code> are variable. There's a top and bottom constraint on the web view to fit to the cell.</p>

<p>When I get the webpage height, I want it to be reflected in the cell's height.</p>