sandy
sandy

Reputation: 23

how to back from third viewController to first viewcontroller?

I've a problem that I move from first viewcontroller to third viewcontroller by pushviewcontroller but when i do popViewControllerAnimated it comes to second viewcontroller but I need to come to first. pls some one help me

Upvotes: 1

Views: 596

Answers (2)

Janak Nirmal
Janak Nirmal

Reputation: 22726

You can use popToViewController as follows

 [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:o] animated:YES];

and similarly you can also use following statement to reach directly to first view controller where you started.

 [self.navigationController popToRootViewControllerAnimated:YES];

Hope it helps.

Upvotes: 4

FoJjen
FoJjen

Reputation: 774

[[self navigationController] popToRootViewControllerAnimated:NO]; 

Upvotes: 2

Related Questions