Navigate Back to previous view controller

ios, objective-c, uinavigationcontroller

Solution

You need to use:

[self.navigationController popToRootViewControllerAnimated:YES];

This will bring you back to the root view controller.

If you want to navigate back to previous view controller, you should implement:

[self.navigationController popViewControllerAnimated:YES];

Problem

I have a `UIView->UICollectionView->UICollectionViewCell`. I am trying to navigate back programatically but none of these works. The code did called. I am using StoryBoard. ``` - (void) goBack:(NSNotification *) notification { // [self.navigationController popViewControllerAnimated:YES]; // [self dismissViewControllerAnimated:YES completion:nil]; [self.navigationController popToRootViewControllerAnimated:YES]; } ```

Original source

Related problems