Instance Method


Pops view controllers until the specified view controller is at the top of the navigation stack.


- (NSArray<__kindof UIViewController *> *)popToViewController:(UIViewController *)viewController animated:(BOOL)animated;



The view controller that you want to be at the top of the stack. This view controller must currently be on the navigation stack.


Set this value to YES to animate the transition. Pass NO if you are setting up a navigation controller before its view is displayed.

Return Value

An array containing the view controllers that were popped from the stack.


For information on how the navigation bar is updated, see Updating the Navigation Bar.

See Also

Pushing and Popping Stack Items

- pushViewController:animated:

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

- popViewControllerAnimated:

Pops the top view controller from the navigation stack and updates the display.

- popToRootViewControllerAnimated:

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


The gesture recognizer responsible for popping the top view controller off the navigation stack.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software