<!--
{
  "availability" : [
    "iOS: 6.0.0 -",
    "iPadOS: 6.0.0 -",
    "macCatalyst: 13.1.0 -",
    "tvOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIViewController/updateViewConstraints()",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(cs)UIViewController(im)updateViewConstraints"
  },
  "title" : "updateViewConstraints()"
}
-->

# updateViewConstraints()

Notifies the view controller when its view needs to update its constraints.

```
func updateViewConstraints()
```

## Discussion

Override this method to optimize changes to your constraints.

> Note:
> It is almost always cleaner and easier to update a constraint immediately after the affecting change has occurred. For example, if you want to change a constraint in response to a button tap, make that change directly in the button’s action method.
> 
> You should only override this method when changing constraints in place is too slow, or when a view is producing a number of redundant changes.

To schedule a change, call [`setNeedsUpdateConstraints()`](/documentation/UIKit/UIView/setNeedsUpdateConstraints()) on the view. The system then calls your implementation of [`updateViewConstraints()`](/documentation/UIKit/UIViewController/updateViewConstraints()) before the layout occurs. This lets you verify that all necessary constraints for your content are in place at a time when your 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 call [`setNeedsUpdateConstraints()`](/documentation/UIKit/UIView/setNeedsUpdateConstraints()) inside your implementation. Calling [`setNeedsUpdateConstraints()`](/documentation/UIKit/UIView/setNeedsUpdateConstraints()) schedules another update pass, creating a feedback loop.

> Important:
> Call `[super updateViewConstraints]` as the final step in your implementation.

In iOS 18 and later, UIKit supports automatic trait tracking inside this method for traits from this view controller’s `traitCollection` and the `traitCollection` of its [`view`](/documentation/UIKit/UIViewController/view). For more information, see [Automatic trait tracking](/documentation/UIKit/automatic-trait-tracking).

This method supports automatic observation tracking. For more information, see [Updating views automatically with observation tracking in UIKit](/documentation/UIKit/updating-views-automatically-with-observation-tracking-in-uikit).

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)