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

# didMove(toParent:)

Called after the view controller is added or removed from a container view controller.

```
func didMove(toParent parent: UIViewController?)
```

## Parameters

`parent`

The parent view controller, or `nil` if there is no parent.

## Discussion

Your view controller can override this method when it wants to react to being added to a container.

If you are implementing your own container view controller, it must call the [`didMove(toParent:)`](/documentation/UIKit/UIViewController/didMove(toParent:)) method of the child view controller after the transition to the new controller is complete or, if there is no transition, immediately after calling the [`addChild(_:)`](/documentation/UIKit/UIViewController/addChild(_:)) method.

The [`removeFromParent()`](/documentation/UIKit/UIViewController/removeFromParent()) method automatically calls the [`didMove(toParent:)`](/documentation/UIKit/UIViewController/didMove(toParent:)) method of the child view controller after it removes the child.

---

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)