---
title: "preferredContentSizeDidChange(for:)"
framework: appkit
role: symbol
role_heading: Instance Method
path: "appkit/nsviewcontroller/preferredcontentsizedidchange(for:)"
---

# preferredContentSizeDidChange(for:)

Called when there is a change in value of the preferredContentSize property of a child view controller or a presented view controller.

## Declaration

```swift
func preferredContentSizeDidChange(for viewController: NSViewController)
```

## Parameters

- `viewController`: The view controller whose doc://com.apple.appkit/documentation/AppKit/NSViewController/preferredContentSize property value changed.

## Discussion

Discussion Override this method if you want to adjust layout when a child view controller or presented view controller changes its preferred content size.

## See Also

### Managing Child View Controllers in a Custom Container

- [addChild(_:)](appkit/nsviewcontroller/addchild(_:).md)
- [children](appkit/nsviewcontroller/children.md)
- [transition(from:to:options:completionHandler:)](appkit/nsviewcontroller/transition(from:to:options:completionhandler:).md)
- [insertChild(_:at:)](appkit/nsviewcontroller/insertchild(_:at:).md)
- [removeChild(at:)](appkit/nsviewcontroller/removechild(at:).md)
- [removeFromParent()](appkit/nsviewcontroller/removefromparent().md)
