0

I created a custom transition for navigation controller where as the user pans up, the next controller's view revealed below as the current controller's view moves in upward direction. I want that view to move by following the touch (as if it is glued to finger at the touch point), but i dont know how to pass that translation from pan gesture recognizer to the object that implements UIViewControllerAnimatedTransitioning. Well, I do but i cannot access it from inside the [UIView animateWithDuration ... ] block (It seems that block is executed once, I thought it would be executed as percentage of completion changes). How can I accomplish this?

To ask the question in a different way, if you use the Photos app in ios7, when you are looking at a photo, touch with two fingers and pinch /move and you will see that it is following the finger (movements). Any example code for this?

Nihat
  • 3,055
  • 3
  • 18
  • 28

2 Answers2

1

You'll need to create a separate animation controller as a subclass of UIPercentDrivenInteractiveTransition to go along with your custom transition animation. This is the class that will calculate the percentage of how complete your animation is. There's too much to explain in a single SO answer, but have a look at the docs here. You can also refer to one of my implementations of a custom transition animation with interactive abilities here to see it in action.

chetem
  • 502
  • 3
  • 10
  • UIPercentDrivenInteractiveTransition class has nothing to pass the gesture translation info. That class is helpful when you have a predefined animation with predefined path. I am trying to make a transition whose path depends on the touch location of the user. – Nihat May 08 '14 at 19:22
  • the `UIViewControllerTransitioningDelegate` has a method `interactionControllerForDismissal:` where you pass in your custom `UIPercentDrivenInteractiveTransition` controller. This is what allows you to animate your transition using a gesture to calculate the percentage of completion. matt also provided useful code samples to see how it is done. – chetem May 08 '14 at 19:29
  • Ok, I will look further into it. Also, your second link seems like what I need (need to download and check it out). I will get back – Nihat May 08 '14 at 19:31
1

Croberth's answer is correct. You actually have two choices.

matt
  • 515,959
  • 87
  • 875
  • 1,141
  • For item #1, see explanations above for croberth; For item #2, thanks :) it gives me idea about how to proceed. I will come back to accept if it solves my problem. – Nihat May 08 '14 at 19:26
  • croberth's second link solved my problem. Your second link would solve it as well but I had to accept his answer because it solves my problem and he was the first to answer. Thanks a lot for your answer. I voted it up as well. – Nihat May 08 '14 at 19:39
  • @Nihat Yup, makes sense. I'm glad to have my links in your answer, as they may help someone else. – matt May 09 '14 at 01:20