Custom animation between UIViewControllers using transitionFromViewController:toViewController:duration

Viewed 6610

I am trying to use UIViewController's transitionFromViewController:toViewController:duration method but with a custom animation.

I have the following two view controllers added as children to a custom container UIViewController:

  1. firstController - This is an instance of UITabBarController
  2. secondController - This is a subclass of UIViewController

The following code works as expected:

[self transitionFromViewController:firstController
                  toViewController:secondController 
                          duration:2                                         
                           options:UIViewAnimationOptionTransitionFlipFromLeft  
                        animations:^(void){} 
                        completion:^(BOOL finished){}];

However I would like to create a custom animation where the where firstController slides to the left and is replaced by secondController sliding in from the right similar to how UINavigationControllers push and pop methods work. After changing the options to UIViewAnimationOptionTransitionNone I have tried to implement custom animations in the animations block but have had absolutely no success. firstController is immediately swapped for secondController without and animations.

I would really appreciate any help.

Thank you

1 Answers
Related