Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transition Delegate for UITabBarController animation

I have a custom UIViewControllerAnimationTransition class created already, and need to make this animate a UITabBarController when it switches tabs.

The tabBarController does not use the regular tab bar, though. I have a custom implementation that acts like it, and when a button is pressed, it calls this code:

tabBarController.selectedIndex = index

Currently I have the tabBarController (subclass) as the delegate for its own transitionDelegate. The delegate method animationControllerForPresentedController is never actually called, though.

Is it fine for the tab bar controller to be its own delegate? If so, why is the transition code never actually called?

like image 729
erdekhayser Avatar asked Jul 24 '14 01:07

erdekhayser


1 Answers

animationControllerForPresentedController is the wrong approach for the tab bar controller.

In the UITabBarController subclass, adopt the UITabBarControllerDelegate protocol and set it as its own delegate. Then, use tabBarController: animationControllerForTransitionFromViewController: toViewController: to return the custom UIViewControllerAnimatedTransitioning object.

To get a better visualization, look at VCTransitionsLibrary in the TabBarDemo folder.

like image 146
erdekhayser Avatar answered Oct 28 '22 21:10

erdekhayser