title: Having trouble getting UIView sizeToFit to do anything meaningful
body: <p>When I add a subview to a <code>UIView</code>, or when I resize an existing subview, I would expect <code>[view sizeToFit]</code> and <code>[view sizeThatFits]</code> to reflect that change. However, my experience is that <code>sizeToFit</code> does nothing, and <code>sizeThatFits</code> returns the same value before and after the change.</p>
  
  <p>My test project has a single view that contains a single button. Clicking the button adds another button to the view and then calls <code>sizeToFit</code> on the containing view. The bounds of the view are dumped to the console before and after adding the subview.</p>
  
  <pre><code>- (void) logSizes {
   NSLog(@"theView.bounds: %@", NSStringFromCGRect(theView.bounds));
   NSLog(@"theView.sizeThatFits: %@", NSStringFromCGSize([theView sizeThatFits:CGSizeZero])); 
  }
  
  - (void) buttonTouched { 
   [self logSizes];
   UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
   btn.frame = CGRectMake(10.0f, 100.0f, 400.0f, 600.0f);
   [theView addSubview:btn];
   [theView sizeToFit];
   [self performSelector:@selector(logSizes) withObject:nil afterDelay:1.0];
  }
  </code></pre>
  
  <p>And the output is:</p>
  
  <pre><code>2010-10-15 15:40:42.359 SizeToFit[14953:207] theView.bounds: {{0, 0}, {322, 240}}
  2010-10-15 15:40:42.387 SizeToFit[14953:207] theView.sizeThatFits: {322, 240}
  2010-10-15 15:40:43.389 SizeToFit[14953:207] theView.bounds: {{0, 0}, {322, 240}}
  2010-10-15 15:40:43.391 SizeToFit[14953:207] theView.sizeThatFits: {322, 240}
  </code></pre>
  
  <p>I must be missing something here.</p>
  
  <p>Thanks.</p>