title: Autoresize UITextView and UIScrollView
body: <p>I already did several searches on Stack Overflow and Google, but I couldn't find a solution to my problem.</p>
  
  <p>I have a Detail View for a product that includes a UIScrollView and a few subviews (UIImageView, UILabel, UITextView). You can find an example <a href="http://drp.ly/hQZf1" rel="noreferrer">here</a>.</p>
  
  <p>First I wanna autoresize the UITextView (not the text itself!) to the corresponding height. Then I wanna autoresize the entire UIScrollView so that it fits the height of my UITextView and the elements above it. I've tried the following code:</p>
  
  <pre><code>myUITextView.frame = CGRectMake(2.0, 98.0, 316.0, self.view.bounds.size.height);
  
  [scrollView setContentOffset:CGPointMake(0.0, 0.0) animated:NO];
  scrollView.contentSize = CGSizeMake(320.0, 98.0 + [myUITextView frame].size.height);
  
  [self.view addSubview:scrollView];
  </code></pre>
  
  <p><em>98.0 + [myUITextView frame].size.height)</em> because my thought was: After getting the height of myUITextView, add the height of the other subviews (98.0) to it.</p>
  
  <p>Unfortunately it doesn't work very well. Depending on the content of the UIScrollView, it is too short or too long. I did some logging with the result that the height of the UITextView is always the same: </p>
  
  <blockquote>
    <p>2010-01-27 14:15:45.096 myApp[1362:207] [myUITextView frame].size.height: 367.000000</p>
  </blockquote>
  
  <p>Thanks!</p>