title: What is NSLayoutConstraint "UIView-Encapsulated-Layout-Height" and how should I go about forcing it to recalculate cleanly?
body: <p>I have a <code>UITableView</code> running under iOS 8 and I'm using automatic cell heights from constraints in a storyboard.</p>
  
  <p>One of my cells contains a single <code>UITextView</code> and I need it to contract and expand based on user input - tap to shrink/expand the text.</p>
  
  <p>I'm doing this by adding a runtime constraint to the text view and changing the constant on the constraint in response to user events:</p>
  
  <pre><code>-(void)collapse:(BOOL)collapse; {
  
      _collapsed = collapse;
  
      if(collapse)
          [_collapsedtextHeightConstraint setConstant: kCollapsedHeight]; // 70.0
      else
          [_collapsedtextHeightConstraint setConstant: [self idealCellHeightToShowFullText]];
  
      [self setNeedsUpdateConstraints];
  
  }
  </code></pre>
  
  <p>Whenver I do this, I wrap it in <code>tableView</code> updates and call <code>[tableView setNeedsUpdateConstraints]</code>:</p>
  
  <pre><code>[tableView beginUpdates];
  
  [_briefCell collapse:!_showFullBriefText];
  
  [tableView setNeedsUpdateConstraints];
  // I have also tried 
  // [self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationTop];
  // with exactly the same results.
  
  [tableView endUpdates];
  </code></pre>
  
  <p>When I do this, my cell does expand (and animates whilst doing it) but I get a constraints warning:</p>
  
  <pre><code>2014-07-31 13:29:51.792 OneFlatEarth[5505:730175] 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:0x7f94dced2b60 V:[UITextView:0x7f94d9b2b200'Brief text: Lorem Ipsum i...'(388)]&gt;",
  
      "&lt;NSLayoutConstraint:0x7f94dced2260 V:[UITextView:0x7f94d9b2b200'Brief text: Lorem Ipsum i...']-(15)-|   (Names: '|':UITableViewCellContentView:0x7f94de5773a0 )&gt;",
  
      "&lt;NSLayoutConstraint:0x7f94dced2350 V:|-(6)-[UITextView:0x7f94d9b2b200'Brief text: Lorem Ipsum i...']   (Names: '|':UITableViewCellContentView:0x7f94de5773a0 )&gt;",
  
      "&lt;NSLayoutConstraint:0x7f94dced6480 'UIView-Encapsulated-Layout-Height' V:[UITableViewCellContentView:0x7f94de5773a0(91)]&gt;"
   )
  
  Will attempt to recover by breaking constraint 
  
  &lt;NSLayoutConstraint:0x7f94dced2b60 V:[UITextView:0x7f94d9b2b200'Brief text: Lorem Ipsum i...'(388)]&gt;
  </code></pre>
  
  <p>388 is my calculated height, the other constraints on the <code>UITextView</code> are mine from Xcode/IB.</p>
  
  <p>The final one is bothering me - I'm guessing that <code>UIView-Encapsulated-Layout-Height</code> is the calculated height of the cell when it is first rendered - (I set my <code>UITextView</code> height to be >= 70.0) however it doesn't seem right that this derived constraint then overrules an updated user cnstraint.</p>
  
  <p>Worse, although the layout code says it's trying to break my height constraint, it doesn't - it goes on to recalculate the cell height and everything draws as I would like.</p>
  
  <p>So, what is <code>NSLayoutConstraint</code> <code>UIView-Encapsulated-Layout-Height</code> (I'm guessing it is the calculated height for automatic cell sizing) and how should I go about forcing it to recalculate cleanly?</p>