title: UIScrollView animation of height and contentOffset "jumps" content from bottom
body: <p>Trying to do something similar to the Messages.app's behavior, I have a <code>UIScrollView</code> and beneath it a text field, and trying to animate it so that when the keyboard appears everything is moved up above the keyboard using a constraint that moves the field up (and the <code>UIScrollView</code>'s height changes as well due to autolayout) and also setting the <code>contentOffset</code> to scroll to the bottom at the same time.  </p>
  
  <p>The code accomplishes the wanted end-result, but during the animation right when the keyboard animation begins the scroll view becomes blank and then the content scrolls up from the bottom, instead of scrolling from the position it was in when the animation started.</p>
  
  <p>The animation is this:</p>
  
  <pre><code>- (void)updateKeyboardConstraint:(CGFloat)height animationDuration:(NSTimeInterval)duration {
      self.keyboardHeight.constant = -height;
      [self.view setNeedsUpdateConstraints];
  
      [UIView animateWithDuration:duration delay:0 options:UIViewAnimationOptionBeginFromCurrentState animations:^{
          [self.view layoutIfNeeded];
          self.collectionView.contentOffset = 
              CGPointMake(0, self.collectionView.contentSize.height - self.collectionView.bounds.size.height);
      } completion:nil];
  }
  </code></pre>
  
  <p>A video of the problem is available <a href="http://cl.ly/202j3W3L3y1r">here</a>.</p>
  
  <p>Thanks!</p>