I implemented my own custom container view controller and I try to make it compatible with iOS 7 view controller transitions. I make my custom container view controller conform to UIViewControllerContextTransitioning
and I send self
when I call transitionDuration:
and animateTransition:
. It all works fine as long as I use only animated transitions.
Now I want to make it work with interactive transitions, so I call the interaction controller's startInteractiveTransition:
instead of the animation controller's animateTransition:
, using self
again as a parameter. However, if I use a UIPercentDrivenInteractiveTransition
as the interaction controller, it then calls a _animator
method on my context (which is the container view controller itself). Of course, I haven't implemented this method which is private and undocumented, so it crashes...
Am I missing something in my implementation? Is UIPercentDrivenInteractiveTransition
only compatible with Apple classes because it uses some implementation magic (as when it requires that everything should be in a UIView
animation block)? The documentation and header files make it look like we can implement our own container view controllers and still use custom transitions, but is it really true or just wishful thinking because nobody would actually do that?
If I can't use UIPercentDrivenInteractiveTransition
, then where exactly should the interaction/animation logic be? In the UIViewControllerTransitionCoordinatorContext
object? In the UIViewControllerInteractiveTransitioning
object (most likely, this object is the driver...)? Or in the UIViewControllerAnimatedTransitioning
object (this is probably where the real animation should happen, but would that mean calling animateTransition:
several times during the interaction? Or adding new methods for each step of the interactive transition?)
Edit: The documentation says:
A percent-driven interactive transition object drives the custom animation between the disappearance of one view controller and the appearance of another. It relies on a transition animator delegate—a custom object that adopts the
UIViewControllerAnimatorTransitioning
protocol—to set up and perform the animations.
There is no UIViewControllerAnimatorTransitioning
protocol. Assuming it is a mistake, or a name change that happened during iOS 7 development and it is actually the UIViewControllerAnimatedTransitioning
protocol, how do we link the interaction controller with the animation controller? I guess it's the responsibility of the view controller driving the transition but I don't see any API to make this link, so it would mean that UIPercentDrivenInteractiveTransition
is indeed reserved for Apple classes?