UIWebView嵌套UIScrollView 获取webVeiw页面高度
因为webView里面有 图片和表格 第一获取的高度可能不太准确需要多获取几次 每次获取不一样重新获取
- (void)updateUI{
NSURL *url
self.MainWebView.scrollView.scrollEnabled = NO;
self.MainWebView.scalesPageToFit = YES;
self.MainWebView.scrollView.delegate = self;
[self.MainWebView loadRequest:[NSURLRequest requestWithURL:url]];
}
#pragma mark - webViewDelegate
- (void)webViewDidFinishLoad:(UIWebView *)webView {
webView.scrollView.scrollEnabled = NO;
CGFloat height = [[webView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight"] floatValue];
DLog(@"-------网页高度--%f",height);
if (self.WebViewHeight.constant != height && self.count <= 3) {
self.WebViewHeight.constant = height;
self.count++;
[self updateUI];
}
}