IOS - resizing UIWebView to fit content?

I need to resize the UIWebView until all the content is visible.

Is it possible?

+7
source share
1 answer

After you have loaded the content in the UIWebView , you can use its stringByEvaluatingJavaScriptFromString: to request an html document by its height. This is a bit complicated, but should work.

You can do something like this:

 NSInteger height = [[webView stringByEvaluatingJavaScriptFromString: @"document.body.scrollHeight"] integerValue]; 

Scrolling couldn't be better. You have several options. Experiment with the document properties listed at http://james.padolsey.com/javascript/get-document-height-cross-browser/

+17
source

All Articles