---
title: "pushViewController(_:animated:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uinavigationcontroller/pushviewcontroller(_:animated:)"
---

# pushViewController(_:animated:)

Pushes a view controller onto the receiver’s stack and updates the display.

## Declaration

```swift
func pushViewController(_ viewController: UIViewController, animated: Bool)
```

## Parameters

- `viewController`: The view controller to push onto the stack. This object cannot be a tab bar controller. If the view controller is already on the navigation stack, this method throws an exception.
- `animated`: Specify doc://com.apple.documentation/documentation/Swift/true to animate the transition or doc://com.apple.documentation/documentation/Swift/false if you do not want the transition to be animated. You might specify doc://com.apple.documentation/documentation/Swift/false if you are setting up the navigation controller at launch time.

## Discussion

Discussion The object in the viewController parameter becomes the top view controller on the navigation stack. Pushing a view controller causes its view to be embedded in the navigation interface. If the animated parameter is true, the view is animated into position; otherwise, the view is simply displayed in its final location. In addition to displaying the view associated with the new view controller at the top of the stack, this method also updates the navigation bar and tool bar accordingly. For information on how the navigation bar is updated, see Updating the navigation bar.

## See Also

### Pushing and popping stack items

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