9

I need to make a button to dismiss the child view controller from a pushViewController. The action is exactly like the left (back) button on the top navigation bar.

How can I dismiss a pushViewController? Which method should I use ?

Thanks.

Jacob Relkin
  • 161,348
  • 33
  • 346
  • 320
user403015
  • 7,209
  • 19
  • 66
  • 100

2 Answers2

15

UINavigationController's popViewControllerAnimated: method should do it.

Jacob Relkin
  • 161,348
  • 33
  • 346
  • 320
7

In my case where [self performSegueWithIdentifier:@"showAllContacts" sender:self]; pushes a new ViewController, in order to close(dismiss) that view controller which has been pushed I use:

[self.navigationController popViewControllerAnimated:YES];

This is called for a custom button which I added to the navigation bar!

swiftBoy
  • 35,607
  • 26
  • 136
  • 135
doruvil
  • 93
  • 1
  • 7