title: Trouble with AutoLayout on UITableViewCell
body: <p>I'm having trouble with autolayout on an <code>xcode 5</code> project.  I am using a plain view controller inside with a navigation controller.  I have a <code>MKMapView</code> on the top half and a <code>UITableView</code> on the bottom half.  I am using <code>storyboards</code>, and have configured the prototype <code>UITableViewCell</code>, but I am adding the constraints through code.  I have double-checked every control in the prototype and don't see any constraints configured there.  My problem occurs when I add the constraints for the <code>UITableViewCell</code>.  I have the following code in the cells:</p>
  
  <pre><code>-(void)updateConstraints {
      [super updateConstraints];
      //first remove old constraints
      [self removeConstraints:self.constraints];
      [self.nameLabel removeConstraints:self.nameLabel.constraints];
      [self.addressLabel removeConstraints:self.nameLabel.constraints];
      [self.rentableSquareFeetLabel removeConstraints:self.rentableSquareFeetLabel.constraints];
      [self.lastSaleAmountLabel removeConstraints:self.lastSaleAmountLabel.constraints];
      [self.lastSaleDateLabel removeConstraints:self.lastSaleAmountLabel.constraints];
      [self.thumbnailImageView removeConstraints:self.thumbnailImageView.constraints];
  
      //then set up constraints
      NSDictionary *viewsDictionary = NSDictionaryOfVariableBindings(_thumbnailImageView, _nameLabel, _rentableSquareFeetLabel, _lastSaleAmountLabel, _addressLabel, _lastSaleDateLabel);
      [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|[_thumbnailImageView(60)]-[_nameLabel(&lt;=200)]-(&gt;=8)-[_rentableSquareFeetLabel]-(&gt;=8)-[_lastSaleAmountLabel]|" options:0 metrics:nil views:viewsDictionary]];
      [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[_nameLabel]-(-4)-[_addressLabel]" options:NSLayoutFormatAlignAllLeading metrics:nil views:viewsDictionary]];
      [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[_lastSaleAmountLabel]-(-4)-[_lastSaleDateLabel]" options:NSLayoutFormatAlignAllLeading metrics:nil views:viewsDictionary]];
  }
  </code></pre>
  
  <p>I am getting the following in the debugging console.  The exception is triggered by the first addConstraints line.  If I just continue through those then eventually everything shows up as it should be, as it looks like xcode is choosing to break the correct constraint:</p>
  
  <pre><code>2013-09-25 15:07:14.169 PECProperties[32381: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;NSIBPrototypingLayoutConstraint:0x9d56c70 'IB auto generated at build time for view with fixed frame' H:|-(0)-[UIImageView:0x9d558f0](LTR)   (Names: '|':UITableViewCellContentView:0x9d55620 )&gt;",
      "&lt;NSIBPrototypingLayoutConstraint:0x9d56d20 'IB auto generated at build time for view with fixed frame' H:[UIImageView:0x9d558f0(60)]&gt;",
      "&lt;NSIBPrototypingLayoutConstraint:0x9d56d80 'IB auto generated at build time for view with fixed frame' H:|-(78)-[UILabel:0x9d559e0](LTR)   (Names: '|':UITableViewCellContentView:0x9d55620 )&gt;",
      "&lt;NSLayoutConstraint:0x9d53830 H:[UIImageView:0x9d558f0]-(NSSpace(8))-[UILabel:0x9d559e0]&gt;" )
  
  Will attempt to recover by breaking constraint  &lt;NSIBPrototypingLayoutConstraint:0x9d56d80 'IB auto generated at build time for view with fixed frame' H:|-(78)-[UILabel:0x9d559e0](LTR)   (Names: '|':UITableViewCellContentView:0x9d55620 )&gt;
  
  Break on objc_exception_throw to catch this in the debugger. The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in &lt;UIKit/UIView.h&gt; may also be helpful.
  </code></pre>
  
  <p>The third NSIBPrototypingLayoutConstraint shows 78 points between the edge of the view and a label.   That is where the prototype is positioned roughly (and if I move it in the prototype, I see the change in the constraint in the debugging console), but that conflicts with my own constraint of "standard" distance between the image view and the label.  </p>
  
  <p>I have tried setting the <code>translatesAutoresizingMaskIntoConstraints=NO</code> in the view controller's  <code>cellForRowAtIndexPath</code>, but that doesn't seem to be helping either.  How can I fix the layout?</p>