<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "tvOS: -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIContentContainer",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(pl)UIContentContainer"
  },
  "title" : "UIContentContainer"
}
-->

# UIContentContainer

A set of methods for adapting the contents of your view controllers to size and trait changes.

```
@MainActor protocol UIContentContainer : NSObjectProtocol
```

## Overview

The methods of this protocol handle size-related transitions that are related to changes in the current trait environment or view controller hierarchy. When the parent view controller changes, or when trait changes occur that affect the size of a view controller, UIKit calls these methods to give the affected objects a chance to respond appropriately.

All [`UIViewController`](/documentation/UIKit/UIViewController) and [`UIPresentationController`](/documentation/UIKit/UIPresentationController) objects provide default implementations for the methods of this protocol. When creating your own custom view controller or presentation controller, you can override the default implementations to make adjustments to your content. For example, you might use these methods to adjust the size or position of any child view controllers.

When overriding the methods of this protocol, call `super` to let UIKit perform any default behaviors. View controllers and presentation controllers perform their own adjustments when these methods are called. Calling `super` ensures that UIKit is able to continue adjusting other parts of your user interface.

## Topics

### Responding to environment changes

[`viewWillTransition(to:with:)`](/documentation/UIKit/UIContentContainer/viewWillTransition(to:with:))

Notifies the container that the size of its view is about to change.

[`willTransition(to:with:)`](/documentation/UIKit/UIContentContainer/willTransition(to:with:))

Notifies the container that its trait collection changed.

### Responding to changes in child view controllers

[`size(forChildContentContainer:withParentContainerSize:)`](/documentation/UIKit/UIContentContainer/size(forChildContentContainer:withParentContainerSize:))

Returns the size of the specified child view controller’s content.

[`preferredContentSizeDidChange(forChildContentContainer:)`](/documentation/UIKit/UIContentContainer/preferredContentSizeDidChange(forChildContentContainer:))

Notifies an interested controller that the preferred content size of one of its children changed.

[`systemLayoutFittingSizeDidChange(forChildContentContainer:)`](/documentation/UIKit/UIContentContainer/systemLayoutFittingSizeDidChange(forChildContentContainer:))

Notifies the container that a child view controller was resized using Auto Layout.

[`preferredContentSize`](/documentation/UIKit/UIContentContainer/preferredContentSize)

The preferred size for the container’s content.



---

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)