---
title: "popToRootViewController(animated:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uinavigationcontroller/poptorootviewcontroller(animated:)"
---

# popToRootViewController(animated:)

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

## Declaration

```swift
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

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

## Discussion

Discussion The root view controller becomes the top view controller. For information on how the navigation bar is updated, see Updating the navigation bar.

## See Also

### Pushing and popping stack items

- [pushViewController(_:animated:)](uikit/uinavigationcontroller/pushviewcontroller(_:animated:).md)
- [popViewController(animated:)](uikit/uinavigationcontroller/popviewcontroller(animated:).md)
- [popToViewController(_:animated:)](uikit/uinavigationcontroller/poptoviewcontroller(_:animated:).md)
- [interactivePopGestureRecognizer](uikit/uinavigationcontroller/interactivepopgesturerecognizer.md)
- [interactiveContentPopGestureRecognizer](uikit/uinavigationcontroller/interactivecontentpopgesturerecognizer.md)
