Edward Hasted
Edward Hasted

Reputation: 3433

UIWebView - how to find the length

I need to know the length of a the output in an UIWebView (in whatever units). Is this possible? Internally IOS must know this to control the scrolling but I can't seem to find it.

Upvotes: 0

Views: 150

Answers (1)

Yonic Surny
Yonic Surny

Reputation: 471

If by length, you mean the height of the content, you can use one of the following in the webViewDidFinishLoad:delegate method:

CGFloat height01 = [[[webView subviews] lastObject] contentSize].height;
CGFloat height02 = [webView sizeThatFits:CGSizeZero].height;
CGFloat height03 = [[webView stringByEvaluatingJavaScriptFromString:@"document.height"] floatValue];

They should return the same value.

Upvotes: 2

Related Questions