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:
- firstController – This is an instance of UITabBarController
- 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
This is actually really easy. For some reason I assumed that the
secondController‘s view would be be under/ behind that offirstController‘s. I had only tried to animate thefirstController‘s view. This of course is wrong. As soon astransitionFromViewController:toViewController:durationis calledsecondController‘s view is placed overfirstController‘s view. The following code works: