문제

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));
    }
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top