title: Swift add constraint programmatically
body: <p>I add a <code>UILabel</code> (amountLabel) in <code>UIViewController</code> in storyboard editor. And then in swift file, <code>viewDidLoad</code>, I programatically create a <code>UITextField</code> (paymentTextField) and try to add a constraint between <code>amountLabel</code> and <code>paymentTextField</code>. Here is my code in <code>viewDidload</code>:</p>
  
  <pre><code>let paymentTextField = UITextField()
      paymentTextField.translatesAutoresizingMaskIntoConstraints = false
      paymentTextField.frame = CGRectMake(15, 100, CGRectGetWidth(self.view.frame) - 30, 44)
      self.view.addSubview(paymentTextField)
  
      let bottonConstraint = NSLayoutConstraint(item: paymentTextField, attribute: NSLayoutAttribute.Bottom, relatedBy: NSLayoutRelation.Equal, toItem: self.amountLabel , attribute: NSLayoutAttribute.Top, multiplier: 1, constant: 30)
      bottonConstraint.identifier = "paymentTextFieldSpacing"
      NSLayoutConstraint.activateConstraints([bottonConstraint])
  </code></pre>
  
  <p>But I get an error:</p>
  
  <blockquote>
    <p>"Terminating app due to uncaught exception 'NSGenericException',
    reason: 'Unable to activate constraint with items > and > because they have no common ancestor. 
    Does the constraint reference items in different view hierarchies? 
    That's illegal."</p>
  </blockquote>
  
  <p>Does anyone know what is wrong? <code>amountLabel</code> is directly dragged to the view in storyboard and "paymentTextField" is added programmatically to the same view. Why have they no common ancestor?</p>