title: Swift returns "The view hierarchy is not prepared for the constraint"
body: <p>I am trying to implement UIScrollView for multiple screens without explicit width to its Contents My Scroll View structure is very simple</p>
  
  <pre><code>                        UIScrollView(Leading , Trialing, Top , Bottom)
                              ContentView (Leading , Trialing, Top , Bottom, Placeholder h/w)
  </code></pre>
  
  <p>Accoring to this  <a href="http://spin.atomicobject.com/2014/03/05/uiscrollview-autolayout-ios/" rel="nofollow noreferrer">Tutiorial</a> adding Left to right constraints to ContentView with respect to main View in ViewDidLoad</p>
  
  <pre><code>            var leftConstraint : NSLayoutConstraint = NSLayoutConstraint(item: self.contentView!, attribute: NSLayoutAttribute.Leading, relatedBy:NSLayoutRelation.Equal, toItem: self.view, attribute: NSLayoutAttribute.Left, multiplier: 1.0, constant: 0)
  
               self.view.addConstraint(leftConstraint)
  
  
              var rightConstraint : NSLayoutConstraint  = NSLayoutConstraint(item:          self.contentView!, attribute: NSLayoutAttribute.Trailing, relatedBy:NSLayoutRelation.Equal, toItem: self.view, attribute: NSLayoutAttribute.Right, multiplier: 1.0, constant: 0)
  
             self.view.addConstraint(rightConstraint)
  </code></pre>
  
  <p>but unfortunately I am getting </p>
  
  <pre><code>       The view hierarchy is not prepared for the constraint: &lt;NSLayoutConstraint:0x7d215170 UIView:0x7be9ac90.leading == UIView:0x7be9af50.left&gt;
  When added to a view, the constraint's items must be descendants of that view (or the view itself). This will crash if the constraint needs to be resolved before the view hierarchy is assembled. Break on -[UIView _viewHierarchyUnpreparedForConstraint:] to debug.
  </code></pre>
  
  <p>How can I resolve it?</p>