While all of the other answers are good, in my mind the question is whether you should be pushing from B
to another copy of itself at all. For me, this is answered by the question of whether you ever want to pop from one B
to the preceding B
. If so, that's fine and use one of the other popToRootViewControllerAnimated
or popToViewController
answers when you want to go back to A
.
If not, you simply shouldn't be pushing from B
to another copy of itself at all. What you could do, though, if you want to present the user to demonstrate "let's do that again" button, you might use transitionWithView
. For example, if we imagine that you have a bunch of UITextField
controls on B
and you have a "Add Another" button, it might do the following:
- (IBAction)onPressAddButton:(id)sender
{
// save the record here
// now, let's animate the resetting of the text fields
[UIView transitionWithView:self.view
duration:0.5
options:UIViewAnimationOptionTransitionCurlUp
animations:^{
self.textField1.text = nil;
self.textField2.text = nil;
self.textField3.text = nil;
}
completion:nil];
}
And, by the way, if you do it this way, you now don't have to do anything fancy to get back from B back to A. The standard navigation bar does everything we need.