I need to get UIWebView height. in method webViewDidFinishLoad I have
CGFloat height1 = [[webView stringByEvaluatingJavaScriptFromString: @"document.body.scrollHeight"] floatValue];
CGFloat height2 = [[webView stringByEvaluatingJavaScriptFromString: @"document.body.offsetHeight"] floatValue];
CGFloat height3 = [[webView stringByEvaluatingJavaScriptFromString: @"document.body.clientHeight"] floatValue];
CGFloat height4 = [[webView stringByEvaluatingJavaScriptFromString: @"document.documentElement.clientHeight"] floatValue];
CGFloat height5 = [[webView stringByEvaluatingJavaScriptFromString: @"document.documentElement.scrollHeight"] floatValue];
CGFloat height6 = [[webView stringByEvaluatingJavaScriptFromString: @"document.documentElement.offsetHeight"] floatValue];
height = MAX(height1, MAX(height2, MAX(height3, MAX(height4, MAX(height5, height6)))));
and still all values are smaller then real value I have this problem only in iOS 10
From Apple forums, your problem seem to have a solution
You can use the javascript func scrollHeight to find what you need.
NSString *heightStr = [webView stringByEvaluatingJavaScriptFromString:@"document.body.scrollHeight;"];
You just need to convert it in a usable float value :
CGFloat webViewHeight = [heightStr floatValue];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With