Suppose you want to click view2 on the right to replace view1.
Then (optionally) implement this method to remove view1 from the view hierarchy:
- (void) pushAnimationDidStop: (NSString *) animationID finished: (NSNumber *) finished context: (void *) context { [view1 removeFromSuperview]; }
In this animation delegate method, you can also free view1 and set its link to nil, depending on whether you need to maintain it after the transition.
source share