第一种方法:
-
-
(void)webViewDidFinishLoad:(UIWebView *)webView -
{
-
CGFloat height = [[webView stringByEvaluatingJavaSc riptFromString:@"document.body.offsetHeight"] floatValue]; -
CGRect frame = webView.frame; -
webView.frame = CGRectMake(frame.origin.x, frame.origin.y, frame.size.width, height); - }
第二种方法:
-(void)webViewDidFinishLoad:(UIWebView *)webView{
CGFloat webViewHeight=[webView.scrollView contentSize].height;
CGRect newFrame = webView.frame;
newFrame.size.height = webViewHeight;
webView.frame = newFrame;
}
CGFloat webViewHeight=[webView.scrollView contentSize].height;
CGRect newFrame = webView.frame;
newFrame.size.height = webViewHeight;
webView.frame = newFrame;
}
【注】:第一种方法不知道为什么计算出来的高度总是少大约10-20的距离;