Hey.
Oh, and I should probably mention that I am not loading the UIWebView with a website, but with an HTML string.
I'm trying to use a UIWebView for displaying content higher than the screen of the iPhone, without needing to scroll in the webView itself.
For that, I need a way to get the total document size, including the scrollable area. I have tried a number of different Javascript solutions:
(document.height !== undefined) ? document.height : document.body.offsetHeight // Returns height of UIWebView
document.body.offsetHeight // Returns zero
document.body.clientHeight // Returns zero
document.documentElement.clientHeight // Returns height of UIWebView
window.innerHeight // Returns height of UIWebView -2
document.body.scrollHeight // Returns zero
Can you think of any other way to do it? Thanks.
EDIT: Can you use sizeThatFits:
here?
Current (nonworking) code:
[[[self.singlePost.contentText subviews] lastObject] setScrollEnabled:NO];
int content_height = [[self.singlePost.contentText stringByEvaluatingJavaScriptFromString: @"document.body.offsetHeight"] intValue];
NSLog(@"Content_height: %d", content_height);
CGRect rect = self.singlePost.contentText.frame;
rect.size.height = content_height;
self.singlePost.contentText.frame = rect;