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];
}
Open object library (shift-command-L) and drag-drop two view controllers on storyboard.
Well, in addition to that, Ctrl+dragging also helps set up segues. So, Ctrl+Drag from the “Go to Other View Controller” button, to somewhere in the second View Controller. It can be anywhere in the main box of the second view controller. When you release, it will show you a box like the one below.
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];
By using below line we can go to parent view controller
[self.navigationController popViewControllerAnimated:YES];
By using below line we can move to main/root view controller
[self.navigationController popToRootViewControllerAnimated:YES];
By using below line we can move to any view controller
[self.navigationController popToViewController:viewControllerObject animated:YES];
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With