Bobyblanco
Bobyblanco

Reputation: 121

Navigation between UIViewControllers IOS

I'm stuck with a problem and ask for your help. It's about navigation within a UINavigationController stack.

For exemple my IOS app can have this type of hierachy

[1]-->[2]-->[3]

Means that the first controller push the second which push the third. How can i create a button in the third one which makes me going back directly to the first controller like this

[3]-->[1]

Thanks for you help

Upvotes: 0

Views: 363

Answers (2)

Stephen Darlington
Stephen Darlington

Reputation: 52565

UINavigationController has the following method:

- (NSArray *)popToRootViewControllerAnimated:(BOOL)animated

You just need to create a button that calls that method.

Upvotes: 2

Andreas Ley
Andreas Ley

Reputation: 9345

Use the UINavigationController's method popToRootViewControllerAnimated:, e.g. from within your UIViewController:

[self.navigationController popToRootViewControllerAnimated:YES];

Upvotes: 2

Related Questions