//页面加载完成之后调用
- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation {
WS(weakSelf);
[webView evaluateJavaScript:@"document.body.offsetHeight;" completionHandler:^(id _Nullable any, NSError * _Nullable error) {
NSString *heightStr = [NSString stringWithFormat:@"%@",any];
weakSelf.webHeight = heightStr.floatValue;
}
这样写的话会获得的内容高度要不实际的高度多出来好大一截
[webView evaluateJavaScript:@”document.body.scrollHeight” completionHandler:^(id _Nullable height, NSError * _Nullable error) {
NSLog(@”scrollHeight : %@”,height);
}];