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

# popToRootViewController(animated:)

Pops all the view controllers on the stack except the root view controller and updates the display.

```
func popToRootViewController(animated: Bool) -> [UIViewController]?
```

## Parameters

`animated`

Set this value to <doc://com.apple.documentation/documentation/Swift/true> to animate the transition. Pass <doc://com.apple.documentation/documentation/Swift/false> if you are setting up a navigation controller before its view is displayed.

## Return Value

An array of view controllers representing the items that were popped from the stack.

## Discussion

The root view controller becomes the top view controller. For information on how the navigation bar is updated, see [`Updating the navigation bar`](/documentation/UIKit/UINavigationController#Updating-the-navigation-bar).

---

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)