我需要能够调整UIWebView的高度,直到所有内容都可见。
这个有可能吗?
这个有可能吗?
在加载了 UIWebView
中的内容后,您可以使用其 stringByEvaluatingJavaScriptFromString:
方法来查询 html 文档的高度。这有点棘手,但应该可以解决。
您可以像这样操作:
NSInteger height = [[webView stringByEvaluatingJavaScriptFromString:
@"document.body.scrollHeight"] integerValue];
scrollheight可能不是最好的选择。你有几个选项。尝试使用http://james.padolsey.com/javascript/get-document-height-cross-browser/中提到的文档属性进行实验。