Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UINavigationController return to first view

I am using a UINavigationController to slide from a UITableViewController to another view. In that second view I have created a custom "Back" button which is attached to an action.

What code do I use to return to dismiss the current view and slide back to my first view? I need something that is the equivalent to [super dismissModalViewControllerAnimated:true]; but obviously this is not a modal view.

Thanks.

like image 489
Nic Hubbard Avatar asked Sep 06 '10 19:09

Nic Hubbard


2 Answers

Look at one of the following three methods on your navigation controller:

popViewControllerAnimated:
popToRootViewControllerAnimated:
popToViewController:animated:

Depending on how you want to handle it of course. Generally one just uses the first method to go back to the last view (the one that pushed your current view onto the navigation stack).

like image 57
jer Avatar answered Nov 08 '22 05:11

jer


Use popToRootViewControllerAnimated method in UINavigationController:

[self.navigationController popToRootViewControllerAnimated:animated];
like image 9
Vladimir Avatar answered Nov 08 '22 03:11

Vladimir