title: UIScrollView contentsize is reset to zero when using auto layout
body: <p>I'm using <code>autolayout</code> to change the height of my <code>scrollview</code>. I add some <code>subviews</code> to the <code>scrollview</code> where I manually increment the content size. But when I get an event where I am about to change the height the content size is zero.</p>
  
  <p><strong>Here is the code:</strong></p>
  
  <pre><code>-(void) addTag:(NSString *)tagName {
  
      ...
      [button addTarget:self action:@selector(tagPressed:) forControlEvents:UIControlEventTouchUpInside];
      [self setContentSize:CGSizeMake(self.frame.size.width, self.contentSize.height+60)];
      [self.items addObject: button];
      NSLog(@"content height: %0.2f", self.contentSize.height);
  
  
  }
  </code></pre>
  
  <p><strong>Console Output:</strong></p>
  
  <pre><code> 2013-04-18 18:23:06.106 TouchSelectApp[19944:c07] content height: 120.00
  </code></pre>
  
  <p><strong>Here I output the contentSize :</strong></p>
  
  <pre><code>- (void)tagPressed:(UIButton *)sender {
  
      NSLog(@"1 content height: %0.2f", self.contentSize.height);
      ...
  }
  </code></pre>
  
  <p><strong>The console shows:</strong> </p>
  
  <pre><code> 2013-04-18 18:17:24.747 TouchSelectApp[19944:c07] 1 content height: 0.00
  </code></pre>
  
  <p>I don't why the content height is set to zero. Help Me!</p>
  
  <p>Update: Here is the problem I am trying to solve.</p>
  
  <p>I am have a scroll view with buttons. Initially it only shows one button. When the button is pressed tagPressed: is called. Tag Pressed changes the height to show all the buttons. Then when the user selects a button the scrollview's height is changed to the original and the offset is set to the button's origin. The below code works but the animation is all wrong. If I change the offset and before the animation block then it just sets the offset to zero. </p>
  
  <pre><code>- (void)tagPressed:(UIButton *)sender {
  
       CGPoint p;
       float maxHeight = self.items.count * 60;
  
  
       if (self.height.constant == maxHeight) {
          self.height.constant = 60;
          p = CGPointMake(0, sender.frame.origin.y-5);     
       }else {
           self.height.constant = maxHeight;
           p = CGPointMake(0, 0);
       }
  
       [self.superview setNeedsUpdateConstraints];
  
       [UIView animateWithDuration:0.5f animations: ^{
            [self.superview layoutIfNeeded];
       } completion:^(BOOL finished) {
            [self setContentOffset:p];
  
       }];
  </code></pre>
  
  <p>}</p>