Instance Method

updateConstraints

Update constraints for the view.

Declaration

- (void)updateConstraints;

Discussion

Override this method to optimize changes to your constraints.

To schedule a change, set the view’s needsUpdateConstraints property to YES. The system then calls your implementation of updateConstraints before the layout occurs. This lets you verify that all necessary constraints for your content are in place at a time when your custom view’s properties are not changing.

Your implementation must be as efficient as possible. Do not deactivate all your constraints, then reactivate the ones you need. Instead, your app must have some way of tracking your constraints, and validating them during each update pass. Only change items that need to be changed. During each update pass, you must ensure that you have the appropriate constraints for the app’s current state.

Do not set the needsUpdateConstraints property inside your implementation. Setting needsUpdateConstraints to YES schedules another update pass, creating a feedback loop.

See Also

Triggering Auto Layout

needsLayout

A Boolean value indicating whether the view needs a layout pass before it can be drawn.

- layout

Perform layout in concert with the constraint-based layout system.

- layoutSubtreeIfNeeded

Updates the layout of the receiving view and its subviews based on the current views and constraints.

needsUpdateConstraints

A Boolean value indicating whether the view’s constraints need to be updated.

- updateConstraintsForSubtreeIfNeeded

Updates the constraints for the receiving view and its subviews.