I've tried the scroll view KVO and I've tried evaluating javascript on the document, using things like clientHeight
, offsetHeight
, etc...
What worked for me eventually is: document.body.scrollHeight
. Or use the scrollHeight
of your top most element, e.g. a container div
.
I listen to the loading
WKWebview property changes using KVO and when it's done loading I determine the height like so:
[self.webview evaluateJavaScript: @"document.body.scrollHeight"
completionHandler: ^(id response, NSError *error) {
NSLog(@"Document height: %@", response);
}];