Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I trigger an update to all the autolayout constraints?

Tags:

ios

autolayout

I modified programmatically one autolayout constraint. It takes effect on one certain view, but other views that are bound with other constraints to that view, do not change their positions. Is there an "updateAllConstraints" method?

like image 758
János Avatar asked Dec 08 '13 09:12

János


People also ask

How do I change constraints in Xcode?

Clicking the Edit button in any of the constraints brings up a popover where you can change the constraint's relationship, constant, priority, or multiplier. To make additional changes, double-click the constraint to select it and open it in the Attribute inspector.


1 Answers

Call those two methods on the view you want to be updated:

-setNeedsLayout
-layoutIfNeeded

The first one says to the layout system that this view needs to be laid out, because it has some changes and, everything should be recalculated. The second force the layout system to be run now, layout system is triggered at specific times during runtime, with this method you are saying:"do it now".

like image 105
Andrea Avatar answered Sep 30 '22 22:09

Andrea