Activating a constraint which was uninstalled in the storyboard

Viewed 467

I have a view which contains a few constraints. Some of them have the Installed checkbox turned off. I am trying to activate and deactivate specific constraints depending on the state of my application.

The problem is that when the installed checkbox is turned off I can't activate the constraints and also I can't deactivate the installed constraints. I need to mention that I use strong references for the constraints in my size classes properties. I also tried an approach to call setNeedsUpdateConstraints and updateConstraintsIfNeeded, setNeedsLayout and layoutIfNeeded, after activating/deactivating the constraints.

I couldn't find any documentation regarding this behavior so why is this happening?

3 Answers

You can set the .isActive property at any time. Remember however to include it on the main thread by using DispatchQueue.main.async { ... }

Related