title: Autolayout constraints conflict
body: <p>Trying to create a view with a <code>UITextField</code> and <code>UILabel</code> beyond it.
  What's wrong with the following code?</p>
  
  <pre><code>- (UIView *)tableHeaderView{
      NSArray *constraints;
      UIView *view = [[UIView alloc]initWithFrame:(CGRect){0,0,self.view.frame.size.width, 88}];
  
      UITextField *tf = [[UITextField alloc]init];
      tf.borderStyle = UITextBorderStyleRoundedRect;
      tf.text = _filter.name;
      [view addSubview:tf];
  
      UILabel *titleLabel = [[UILabel alloc] init];
      titleLabel.textAlignment = NSTextAlignmentCenter;
      titleLabel.translatesAutoresizingMaskIntoConstraints = NO;
      titleLabel.text = [NSString stringWithFormat:NSLocalizedString(@"Found results: %d", nil), _filter.resultsCount];
      [view addSubview:titleLabel];
  
      constraints = [NSLayoutConstraint constraintsWithVisualFormat:@"|-[titleLabel]-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(titleLabel)];
      [view addConstraints:constraints];
  
      constraints = [NSLayoutConstraint constraintsWithVisualFormat:@"|-[tf]-|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(tf)];
      [view addConstraints:constraints];
  
      constraints = [NSLayoutConstraint constraintsWithVisualFormat:@"V:|[titleLabel]-8-[tf]|" options:0 metrics:nil views:NSDictionaryOfVariableBindings(titleLabel, tf)];
      [view addConstraints:constraints];
  }
  </code></pre>
  
  <p>Error message:</p>
  
  <pre><code>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:0x15dd2fc0 V:|-(0)-[UILabel:0x15dd1e10]   (Names: '|':UIView:0x15dc4f90 )&gt;",
      "&lt;NSLayoutConstraint:0x15dd3120 V:[UILabel:0x15dd1e10]-(8)-[UITextField:0x15dbe780]&gt;",
      "&lt;NSAutoresizingMaskLayoutConstraint:0x15de2300 h=--&amp; v=--&amp; UITextField:0x15dbe780.midY ==&gt;"
  )
  
  Will attempt to recover by breaking constraint 
  &lt;NSLayoutConstraint:0x15dd3120 V:[UILabel:0x15dd1e10]-(8)-[UITextField:0x15dbe780]&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.
  2014-07-14 14:01:30.216 DossierPolice[4724:60b] 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:0x15dd2e20 H:[UITextField:0x15dbe780]-(NSSpace(20))-|   (Names: '|':UIView:0x15dc4f90 )&gt;",
      "&lt;NSAutoresizingMaskLayoutConstraint:0x15de1ee0 h=--&amp; v=--&amp; UITextField:0x15dbe780.midX ==&gt;",
      "&lt;NSAutoresizingMaskLayoutConstraint:0x15de22d0 h=--&amp; v=--&amp; H:[UITextField:0x15dbe780(0)]&gt;",
      "&lt;NSAutoresizingMaskLayoutConstraint:0x13a9eda0 h=--&amp; v=--&amp; H:[UIView:0x15dc4f90(320)]&gt;"
  )
  
  Will attempt to recover by breaking constraint 
  &lt;NSLayoutConstraint:0x15dd2e20 H:[UITextField:0x15dbe780]-(NSSpace(20))-|   (Names: '|':UIView:0x15dc4f90 )&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.
  2014-07-14 14:01:30.217 DossierPolice[4724:60b] 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:0x15dd3160 V:[UITextField:0x15dbe780]-(0)-|   (Names: '|':UIView:0x15dc4f90 )&gt;",
      "&lt;NSAutoresizingMaskLayoutConstraint:0x15de2300 h=--&amp; v=--&amp; UITextField:0x15dbe780.midY ==&gt;",
      "&lt;NSAutoresizingMaskLayoutConstraint:0x15de2330 h=--&amp; v=--&amp; V:[UITextField:0x15dbe780(0)]&gt;",
      "&lt;NSAutoresizingMaskLayoutConstraint:0x13a9ee00 h=--&amp; v=--&amp; V:[UIView:0x15dc4f90(88)]&gt;"
  )
  
  Will attempt to recover by breaking constraint 
  &lt;NSLayoutConstraint:0x15dd3160 V:[UITextField:0x15dbe780]-(0)-|   (Names: '|':UIView:0x15dc4f90 )&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>