Programmatically call navigation controller back button on iOS

oberbaum picture oberbaum · Jan 21, 2010 · Viewed 73.5k times · Source

In a UINavigationController-based iPhone app, in a method I would like to perform the programmatic equivalent of the back button being pressed and going back a view.

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

Navigation Controller image

Is there a generic iOS call I can make, or is more information required?

Answer

Steve Harrison picture Steve Harrison · Jan 21, 2010

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

[navigationController popViewControllerAnimated:YES];