When you use segues, the flow moves back and forth. When a user moves backward (i.e., presses "backward"), he will not click on the new VC, but he will appear in the VC that already exists. When you exit, the current VC is removed from the stack and memory.
If you have transitions to move backward in the stream, this is wrong. You only need to go forward.
PRELIMINARY PREPARATION FOR SEG
In preparation for segue, you should never create your own view controllers and click on them. The storyboard should do it all for you.
The correct prepareForSegue method should look something like this:
- (void)prepareForSegue:(UIStoryBoardSegue*)segue { if([segue.identifier isEqualToString:"SomeSegue"]) { MyNewViewController *controller = segue.destinationViewController; controller.someProperty = "some value to pass in"; } }
That is all you need. Please note that you only need this if you intend to pass some information to the new view controller. If you are not transmitting anything, you do not need this method at all.
When the method ends, the new VC will be popped onto the screen by the storyboard file.
UNWIND SEGUES
If you have a random thread (e.g. in your comment), you can use unwind to achieve this.
Your view controller has a function like ...
- (IBAction)someUnwindAction:(UIStoryboardSegue*)sender {
He needs to get the UIStoryboardSegue object. If you are configured as an IBAction, you can also access it from Interface Builder.
Now that you want to go A> B> C> B> A, just use the standard push and pop buttons (from the segue and back buttons).
When you want to go A> B> C> A, you can use the unwind segue from controller C.
If you have a cancel button or something in controller C, and this is in the Builder interface, and this should return you to controller A. Then in the Builder interface under controller C you will have a small green square with a door and an arrow pointing to this is. Simply indicate the action of the cancel button on this symbol and select "someUnwindAction". (Note that unwindAction is in A, the button is in C.) Then Xcode uses this so that you go back to A all the time and delete any memory and everything. If you want, you can send additional information back to A.
If you want to access this reversal session from C programmatically, you can run ...
[self performSegueWithIdentifier:"someUnwindAction" sender:nil];
This will also return to A.