I need to resize the web view frame according to content height. So I need to calculate the height of content.
This is the solution that i use
NSUInteger contentHeight = [[webView stringByEvaluatingJavaScriptFromString:[NSString stringWithFormat:@"document.body.scrollHeight;"]] intValue];
Your webview should have a frame smaller than all possible content size
Try This,
- (void)webViewDidFinishLoad:(UIWebView *)webView {
CGSize contentSize = webView.scrollView.contentSize;
NSLog(@"Content Size %@", NSStringFromCGSize(contentSize));
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.