views:

1613

answers:

3

hi guys

in my navigation control based iphone app, in a method I would like the programmatic equivalent of the back button being pressed and going back a view.

i.e. automatically press the Jobs button as seen here: alt text

Is there a generic iphone call i can make, or is more information required?

Regards

+1  A: 

You should call

popViewControllerAnimated:

which is the opposite of adding view controllers with pushViewController:animated:

Niels Castle
+3  A: 

UINavigationController's popViewControllerAnimated: method should do what you want:

[navigationController popViewControllerAnimated:YES];
Steve Harrison
awesome, thanks to Steve and Niels. The solution I used was [self.navigationController popViewControllerAnimated:YES];easy ;)
norskben
A: 

Assuming you don't actually want to PRESS the button programmatically, but simply copy the outcome of pressing the button, you should tell the navigation controller to pop the current view controller.

[self.navigationController popViewControllerAnimated:YES];

This will remove it from the stack, and return you to the previous view controller.

Kevin Elliott