Programmatically call navigation controller back button on iOS

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

[navigationController popViewControllerAnimated:YES];

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.


Swift 3.0

Back to the root view

self.navigationController?.popToRootViewController(animated: true)

Back to the previous view

self.navigationController?.popViewController(animated: true)

Swift 2.3

Back to the root view

self.navigationController?.popToRootViewControllerAnimated(true)

Back to the previous view

self.navigationController?.popViewControllerAnimated(true)