title: Unexpected behavior when the constraints are applied for the first time
body: <p>I want to change the layout and constraints relative to the orientation of the device.
  Here's how I implemented it:</p>
  <pre><code>override func viewDidLoad() {
          super.viewDidLoad()
          
          setupViews()
          addViews()
          constraintSubviews()
  }
  func constraintSubviews() {
          if UIDevice.current.orientation.isPortrait {
              NSLayoutConstraint.activate(portraitConstrains)
              NSLayoutConstraint.deactivate(landscapeConstrains)
              NSLayoutConstraint.activate(nowPlayingView.portraitConstrains)
              NSLayoutConstraint.deactivate(nowPlayingView.landscapeConstrains)
              
  
              
          } else {
              NSLayoutConstraint.deactivate(portraitConstrains)
              NSLayoutConstraint.activate(landscapeConstrains)
              NSLayoutConstraint.activate(nowPlayingView.landscapeConstrains)
              NSLayoutConstraint.deactivate(nowPlayingView.portraitConstrains)
             
          }
  }
  override func viewDidLayoutSubviews() {
          super.viewDidLayoutSubviews()
          constraintSubviews()
  }
  </code></pre>
  <p>Here's what I ended up when running the code:</p>
  <p><a href="https://i.stack.imgur.com/C9KDR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/C9KDR.png" alt="enter image description here" /></a></p>
  <p>And this is what I expect:</p>
  <p><a href="https://i.stack.imgur.com/w58Si.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/w58Si.png" alt="enter image description here" /></a></p>
  <p>I can't get the layout I designed in the code unless I change device orientation once.</p>
  <p><a href="https://i.stack.imgur.com/3oMvS.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3oMvS.gif" alt="enter image description here" /></a></p>
  <p><strong>Better implementation</strong></p>
  <p>I've searched all over the Internet and the best thing I found was this implementation. Is there a better implementation regarding this subject?</p>