title: When to update constraints with AutoLayout in iOS 7
body: <p>In my application I want to resize a UITextView (<code>self.message</code>), Navigation Controller's view and I want to change the position of a UIScrollView (<code>self.selectedMedia</code>) when the keyboard shows. To accomplish that I'm using this delegate method:</p>
  
  <pre><code>- (void)keyboardWillShow:(NSNotification *)notification
  {
  NSDictionary* userInfo = [notification userInfo];
  
  NSTimeInterval animationDuration;
  UIViewAnimationCurve animationCurve;
  CGRect keyboardFrame;
  CGRect navigationControllerFrame = self.navigationController.view.frame;
  CGRect textViewFrame = self.message.frame;
  CGFloat keyboardHeight;
  
  [[userInfo objectForKey:UIKeyboardAnimationCurveUserInfoKey] getValue:&amp;animationCurve];
  [[userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] getValue:&amp;animationDuration];
  [[userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey] getValue:&amp;keyboardFrame];
  
  keyboardHeight = keyboardFrame.size.height;
  
  [UIView beginAnimations:nil context:nil];
  [UIView setAnimationDuration:animationDuration];
  [UIView setAnimationCurve:animationCurve];
  
  [self.navigationController.view setFrame:CGRectMake(
                                                      navigationControllerFrame.origin.x,
                                                      navigationControllerFrame.origin.y,
                                                      navigationControllerFrame.size.width,
                                                      navigationControllerFrame.size.height - keyboardHeight
                                                      )];
  [self.message setFrame:CGRectMake(
                                    textViewFrame.origin.x,
                                    textViewFrame.origin.y,
                                    textViewFrame.size.width,
                                    textViewFrame.size.height - keyboardHeight)];
  
  if (self.selectedMedia.hidden == NO) {
      [self.selectedMedia setFrame:CGRectMake(
                                              self.selectedMedia.frame.origin.x,
                                              self.selectedMedia.frame.origin.y - keyboardHeight,
                                              self.selectedMedia.frame.size.width,
                                              self.selectedMedia.frame.size.height
                                              )];
  }
  
  [self.navigationController.view updateConstraints];
  [UIView commitAnimations];
  }
  </code></pre>
  
  <p>When I run this code, I get an error that the constraints cannot be satisfied:</p>
  
  <pre><code>2013-10-11 14:03:52.532 PoC[78199:a0b] Unable to simultaneously satisfy constraints.
  Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted constraint or constraints and fix it. (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
  (
  "&lt;NSLayoutConstraint:0xe5502d0 V:[UITextView:0xf26da00(380)]&gt;",
  "&lt;NSLayoutConstraint:0x8b93620 V:|-(0)-[UITextView:0xf26da00]   (Names: '|':UIView:0x8b978f0 )&gt;",
  "&lt;NSLayoutConstraint:0x8b984c0 V:[UIScrollView:0x8b8f570]-(0)-|   (Names: '|':UIView:0x8b978f0 )&gt;",
  "&lt;NSLayoutConstraint:0x8b98520 V:[UITextView:0xf26da00]-(0)-[UIScrollView:0x8b8f570]&gt;",
  "&lt;NSAutoresizingMaskLayoutConstraint:0x8b9acf0 h=--&amp; v=--&amp; V:[UIView:0x8b978f0(244)]&gt;"
  )
  
  Will attempt to recover by breaking constraint 
  &lt;NSLayoutConstraint:0xe5502d0 V:[UITextView:0xf26da00(380)]&gt;
  </code></pre>
  
  <p>I wonder why the UITextView still has a height of 380. Doesn't the statement <code>[self.navigationController updateConstraints]</code> adjust the height based on the given constraints? Should the constraints be updated after committing the animation? Or is there something else I'm overlooking?</p>