IOS on webView (a) – calculate the actual content of the webView display

Before the project needs a view above web is the native, how to calculate the height of the layout of the following web view.y.
eg: above is below the news comments, comments to use the native implementation.

The two method, method 1 can get the actual height of the content, method 2 has been given the contents of the full display of the size of the webView (including UIEdgeInsets)

- (void) webViewDidFinishLoad: (UIWebView * webView) {/ / 1 methods using JS method to achieve CGFloat documentWidth = [[webView stringByEvaluatingJavaScriptFromString:@ document.getElementById ('content').OffsetWidth] floatValue] CGFloat [[webView stringByEvaluatingJavaScriptFromString:@; documentHeight = document.getElementById ("content/").OffsetHeight; "floatValue] NSLog"]; (@ documentSize = {%f,%f}. "DocumentWidth, documentHeight); / / CGRect frame 2 = webView.frame; frame.size.width = 768; frame.size.height = 1; / / webView.scrollView.scrollEnabled = NO; webView.frame = frame; frame.size.height = webView.scrollView.contentSize.height; NSLog (@ frame = [NSValue valueWithCGRect:% @", frame]); webView.frame = frame;}

If the height is not allowed

Dispatch_after (dispatch_time (DISPATCH_TIME_NOW (int64_t) (0.1 * NSEC_PER_SEC), queue,
) ^{wrote the above introduced method
});

link

Calculate the actual height of the webView display content

Change UIWebView background color