Setting constraint to inActive keeps breaking it

49 Views Asked by At

I want to switch between 2 constraints when device orientation changed. But even if I set the isActive to false, systems keeps showing me the Unable to simultaneously satisfy constraints. warning and I lost one of those constraints for the whole app life cycle.

override func viewWillLayoutSubviews() {
    super.viewWillLayoutSubviews()
    if UIDevice.current.orientation.isLandscape {
        iPadPortraintWidthConstraint.isActive = false
        iPadLandscapeWidthConstraint.isActive = true
    } else {
        iPadLandscapeWidthConstraint.isActive = false
        iPadPortraintWidthConstraint.isActive = true
    }        
}

What should be done here?

0

There are 0 best solutions below