Rob
Rob

Reputation: 16002

UIWebView : resize/fit according to the content?

I'd like to create a text area with many font formats and colors, so I'm using a UIWebView. No problem to create my HTML text and display it, but I would like to make the view fit to the content.

With a UITextView I used to do the following after the adding to the subView :

CGRect frame = myTextView.frame;
frame.size.height = myTextView.frame.size.height;
myTextView.frame = frame;

But it doesn't work with UIWebView. Any advice please ?

Upvotes: 2

Views: 8453

Answers (2)

joern
joern

Reputation: 27620

I wrote a short tutorial on how to set the height of a UIWebView to the height of it’s HTML content.

Upvotes: 6

nhahtdh
nhahtdh

Reputation: 56829

Resize it to the contentSize of the scrollView of UIWebView.

Upvotes: 4

Related Questions