如何计算iOS中的Web视图内容高度?

Ram*_*ddy 1 uiwebview ios

我需要根据内容高度调整Web视图框的大小.所以我需要计算内容的高度.

小智 5

这是我使用的解决方案

NSUInteger contentHeight = [[webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"document.body.scrollHeight;"]] intValue];
Run Code Online (Sandbox Code Playgroud)

您的网页视图的框架应小于所有可能的内容大小