【发布时间】:2016-09-15 12:15:01
【问题描述】:
我需要获取 UIWebView 的高度。在方法 webViewDidFinishLoad 我有
CGFloat height1 = [[webView stringByEvaluatingJavaScriptFromString: @"document.body.scrollHeight"] floatValue];
CGFloat height2 = [[webView stringByEvaluatingJavaScriptFromString: @"document.body.offsetHeight"] floatValue];
CGFloat height3 = [[webView stringByEvaluatingJavaScriptFromString: @"document.body.clientHeight"] floatValue];
CGFloat height4 = [[webView stringByEvaluatingJavaScriptFromString: @"document.documentElement.clientHeight"] floatValue];
CGFloat height5 = [[webView stringByEvaluatingJavaScriptFromString: @"document.documentElement.scrollHeight"] floatValue];
CGFloat height6 = [[webView stringByEvaluatingJavaScriptFromString: @"document.documentElement.offsetHeight"] floatValue];
height = MAX(height1, MAX(height2, MAX(height3, MAX(height4, MAX(height5, height6)))));
而且所有值仍然小于实际值 我只在 iOS 10 中遇到这个问题
【问题讨论】:
-
webView 高度还是 webView 内容高度?
标签: javascript ios objective-c uiwebview