change direction of segue of pushViewController in iPhone <p>I am using the following code to launch a view controller named secondViewController.</p> <pre><code>[self.navigationController pushViewController:secondViewController animated:YES]; </code></pre> <p>The code successfully causes the secondVC to slide in from the right to left</p> <p>After the user is done I would like the user to be able to go back to the first View Controller. For this purpose I have wired a back button to a method that uses similar code, however in this case I would like it to slide from left to right, i.e. the opposite direction. However, not surprisingly the return VC also goes from right to left.</p> <pre><code>[self.navigationController pushViewController:returnViewController animated:YES]; </code></pre> <p>Is there a way to reverse the direction so that in the second case, it slides from left to right?</p> <p><strong>EDIT:</strong></p> <p>Using the code from the answer suggested by Brendan, I have added the following method to override the pushViewController. I am calling it the same way but have had to comment the swapButtonsForViewController as the selector SwapButtons is not recognized. Not sure what it really does.</p> <p>In addition, if you call it as super, I get an error: no visible@interface in the super VC for this VC. Not sure how to fix that. If I change super to self, error disappears but it still goes right to left.</p> <pre><code>- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated{ UIView *theWindow = self.view ; if( animated ) { CATransition *animation = [CATransition animation]; [animation setDuration:0.45f]; [animation setType:kCATransitionPush]; [animation setSubtype:kCATransitionFromLeft]; [animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]]; [[theWindow layer] addAnimation:animation forKey:@""]; } //make sure we pass the super "animated:NO" or we will get both our //animation and the super's animation [super pushViewController:viewController animated:NO]; // [self swapButtonsForViewController:viewController]; } </code></pre>