Abhinav
Abhinav

Reputation: 38162

Quickly returning to RootViewController

Is there any way to quickly go to rootViewController? I want to remove all views from the stack & return to rootViewController without even bothering the sequence of views on top of it.

Upvotes: 3

Views: 6782

Answers (3)

Kuldeep
Kuldeep

Reputation: 2589

First I think you need to dismiss presented model then you can pop all the pushed view controllers. As presented model would not be in the stack of the navigation.

[self dismissModalViewControllerAnimated:YES];

Then you can pop to base view controller.

[self.navigationController popToRootViewController:YES];

Upvotes: 4

Leena
Leena

Reputation: 2676

Try this:-

[self.viewController popToRootViewController:YES];

Upvotes: 1

CodaFi
CodaFi

Reputation: 43330

From the docs:

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

- (NSArray *)popToRootViewControllerAnimated:(BOOL)animated

Parameters

animated:

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 of view controllers that are popped from the stack.

Upvotes: 8

Related Questions