title: Adding constraints to UITextField programmatically
body: <p>I am learning auto layout without using StoryBoard. I have given four constraints of trailing, leading, top and bottom.</p>
  
  <p><strong>Code:</strong></p>
  
  <pre><code>UITextField *searchBarTF=[[UITextField alloc]init];  
  [searchBarTF setText:@"is it coming?"];
  [views addSubview:searchBarTF];
  
  [views addConstraint:[NSLayoutConstraint constraintWithItem:searchBarTF attribute:NSLayoutAttributeLeading relatedBy:NSLayoutRelationEqual toItem:views attribute:NSLayoutAttributeLeading multiplier:1.0 constant:30]];
  
  [views addConstraint:[NSLayoutConstraint constraintWithItem:searchBarTF attribute:NSLayoutAttributeTrailing   relatedBy:NSLayoutRelationEqual toItem:views attribute:NSLayoutAttributeTrailing multiplier:1.0 constant:30]];
  
  [views addConstraint:[NSLayoutConstraint constraintWithItem:searchBarTF attribute:NSLayoutAttributeTop    relatedBy:NSLayoutRelationEqual toItem:views attribute:NSLayoutAttributeTop multiplier:1.0 constant:30]];
  
  [views addConstraint:[NSLayoutConstraint constraintWithItem:searchBarTF attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:views attribute:NSLayoutAttributeBottom multiplier:1.0 constant:230]];
  </code></pre>
  
  <p>TextField is not appearing on screen.</p>
  
  <p><strong>Error:</strong></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.
  </code></pre>