title: Unable to simultaneously satisfy constraints with animation
body: <p>I have a button that, when pushed,  rotates showing other buttons initially hidden behind it using autolayout.</p>
  
  <p><a href="https://i.stack.imgur.com/Z9Tpe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Z9Tpe.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/Ox2bP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ox2bP.png" alt="enter image description here"></a></p>
  
  <p>The buttons are added with this constraints:</p>
  
  <pre><code>var tennisButtonHiddenConstraint1 : NSLayoutConstraint?
  var tennisButtonHiddenConstraint2 : NSLayoutConstraint?
  var tennisButtonBottomAnchor : NSLayoutConstraint?
  var tennisButtonRightAnchor : NSLayoutConstraint?
  var tennisButtonWidthAnchor : NSLayoutConstraint?
  var tennisButtonHeightAnchor : NSLayoutConstraint?
  
  
  func setupViews(){
          self.mapView.addSubview(tennisButton)
          tennisButtonHiddenConstraint1 =  tennisButton.bottomAnchor.constraint(equalTo: self.mapView.bottomAnchor, constant: -50)
          tennisButtonHiddenConstraint1?.isActive = true
  
          tennisButtonHiddenConstraint2 = tennisButton.centerXAnchor.constraint(equalTo: self.mapView.centerXAnchor)
          tennisButtonHiddenConstraint2?.isActive = true
  
          tennisButtonRightAnchor =  tennisButton.rightAnchor.constraint(equalTo: self.addEventButton.leftAnchor, constant: -20)
          tennisButtonRightAnchor?.isActive = false
  
          tennisButtonBottomAnchor = tennisButton.bottomAnchor.constraint(equalTo: self.addEventButton.topAnchor, constant: 20)
          tennisButtonBottomAnchor?.isActive = false
  
          tennisButtonWidthAnchor  = tennisButton.widthAnchor.constraint(equalToConstant: 66)
          tennisButtonWidthAnchor?.isActive = false
          tennisButtonHeightAnchor  = tennisButton.heightAnchor.constraint(equalToConstant: 66)
          tennisButtonHeightAnchor?.isActive = false
  
          self.mapView.addSubview(addEventButton)
          addEventButton.bottomAnchor.constraint(equalTo: self.mapView.bottomAnchor, constant: -50).isActive = true
          addEventButton.centerXAnchor.constraint(equalTo: self.mapView.centerXAnchor).isActive = true
          addEventButton.widthAnchor.constraint(equalToConstant: 80).isActive = true
          addEventButton.heightAnchor.constraint(equalToConstant: 80).isActive = true
  }
  </code></pre>
  
  <p>and then the animation code is the following: </p>
  
  <pre><code>@objc func showAvailableActions(){
      if menuButtonShown == false {
          self.tennisButtonHiddenConstraint1?.isActive = false
          self.tennisButtonHiddenConstraint2?.isActive = false
          self.tennisButtonBottomAnchor?.isActive = true
          self.tennisButtonRightAnchor?.isActive = true
          self.tennisButtonHeightAnchor?.isActive = true
          self.tennisButtonWidthAnchor?.isActive = true
          menuButtonShown = true
  
          UIView.animate(withDuration: 0.5, animations: {
          self.addEventButton.transform = CGAffineTransform(rotationAngle:  .pi/4)
          })
  
          UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 1.0, initialSpringVelocity: 1.0, options: .curveEaseInOut, animations: {
              self.view.layoutIfNeeded()
      }, completion: nil)
  
      }else{
  
          self.tennisButtonHiddenConstraint1?.isActive = true
          self.tennisButtonHiddenConstraint2?.isActive = true
          self.tennisButtonBottomAnchor?.isActive = false
          self.tennisButtonRightAnchor?.isActive = false
          self.tennisButtonHeightAnchor?.isActive = false
          self.tennisButtonWidthAnchor?.isActive = false
          menuButtonShown = false
  
  
          UIView.animate(withDuration: 0.5, animations: {
              self.addEventButton.transform = CGAffineTransform.identity
          })
          UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 1.0, initialSpringVelocity: 1.0, options: .curveEaseInOut, animations: {
              self.view.layoutIfNeeded()
          }, completion: nil)
  
      }
  }
  </code></pre>
  
  <p>When the buttons is shown everything works fine however when it is hidden I get the following: </p>
  
  <pre><code>Yoofit[7442:9349648] [LayoutConstraints] 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. 
  (
      "&lt;NSLayoutConstraint:0x600000a10f50 Yoofit.AddEventButton:0x7f8584c3beb0.height == 80   (active)&gt;",
      "&lt;NSLayoutConstraint:0x600000a17520 UIButton:0x7f8584c3c3e0.bottom == Yoofit.AddEventButton:0x7f8584c3beb0.top + 20   (active)&gt;",
      "&lt;NSLayoutConstraint:0x600000a17750 Yoofit.AddEventButton:0x7f8584c3beb0.bottom == MKMapView:0x7f858505f200.bottom - 50   (active)&gt;",
      "&lt;NSLayoutConstraint:0x600000a6b980 UIButton:0x7f8584c3c3e0.bottom == MKMapView:0x7f858505f200.bottom - 50   (active)&gt;"
  )
  
  Will attempt to recover by breaking constraint 
  &lt;NSLayoutConstraint:0x600000a10f50 Yoofit.AddEventButton:0x7f8584c3beb0.height == 80   (active)&gt;
  
  Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
  The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in &lt;UIKitCore/UIView.h&gt; may also be helpful.
  2019-07-03 19:51:02.337695+0800 Yoofit[7442:9349648] [LayoutConstraints] 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. 
  (
      "&lt;NSLayoutConstraint:0x600000a17930 Yoofit.AddEventButton:0x7f8584c3beb0.width == 80   (active)&gt;",
      "&lt;NSLayoutConstraint:0x600000a17430 UIButton:0x7f8584c3c3e0.right == Yoofit.AddEventButton:0x7f8584c3beb0.left - 20   (active)&gt;",
      "&lt;NSLayoutConstraint:0x600000a177f0 Yoofit.AddEventButton:0x7f8584c3beb0.centerX == MKMapView:0x7f858505f200.centerX   (active)&gt;",
      "&lt;NSLayoutConstraint:0x600000a174d0 UIButton:0x7f8584c3c3e0.width == 66   (active)&gt;",
      "&lt;NSLayoutConstraint:0x600000a6bf20 UIButton:0x7f8584c3c3e0.centerX == MKMapView:0x7f858505f200.centerX   (active)&gt;"
  )
  
  Will attempt to recover by breaking constraint 
  &lt;NSLayoutConstraint:0x600000a17930 Yoofit.AddEventButton:0x7f8584c3beb0.width == 80   (active)&gt;
  
  Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
  The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in &lt;UIKitCore/UIView.h&gt; may also be helpful.
  2019-07-03 19:51:02.341441+0800 Yoofit[7442:9349648] [LayoutConstraints] 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. 
  (
      "&lt;NSLayoutConstraint:0x600000a17430 UIButton:0x7f8584c3c3e0.right == Yoofit.AddEventButton:0x7f8584c3beb0.left - 20   (active)&gt;",
      "&lt;NSLayoutConstraint:0x600000a177f0 Yoofit.AddEventButton:0x7f8584c3beb0.centerX == MKMapView:0x7f858505f200.centerX   (active)&gt;",
      "&lt;NSLayoutConstraint:0x600000a174d0 UIButton:0x7f8584c3c3e0.width == 66   (active)&gt;",
      "&lt;NSLayoutConstraint:0x600000a6bf20 UIButton:0x7f8584c3c3e0.centerX == MKMapView:0x7f858505f200.centerX   (active)&gt;"
  )
  
  Will attempt to recover by breaking constraint 
  &lt;NSLayoutConstraint:0x600000a174d0 UIButton:0x7f8584c3c3e0.width == 66   (active)&gt;
  
  Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
  The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in &lt;UIKitCore/UIView.h&gt; may also be helpful.
  2019-07-03 19:51:02.360114+0800 Yoofit[7442:9349648] [LayoutConstraints] 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. 
  (
      "&lt;NSLayoutConstraint:0x600000a17430 UIButton:0x7f8584c3c3e0.right == Yoofit.AddEventButton:0x7f8584c3beb0.left - 20   (active)&gt;",
      "&lt;NSLayoutConstraint:0x600000a177f0 Yoofit.AddEventButton:0x7f8584c3beb0.centerX == MKMapView:0x7f858505f200.centerX   (active)&gt;",
      "&lt;NSLayoutConstraint:0x600000a6bf20 UIButton:0x7f8584c3c3e0.centerX == MKMapView:0x7f858505f200.centerX   (active)&gt;"
  )
  
  Will attempt to recover by breaking constraint 
  &lt;NSLayoutConstraint:0x600000a177f0 Yoofit.AddEventButton:0x7f8584c3beb0.centerX == MKMapView:0x7f858505f200.centerX   (active)&gt;
  
  Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
  The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in &lt;UIKitCore/UIView.h&gt; may also be helpful.
  </code></pre>