Ivan Vavilov
Ivan Vavilov

Reputation: 1649

Custom Interactive Transition With Table View

I create custom push/pop interactive transition, but I can't understand how to handle this transition and table view scroll simultaneously.

For handle custom pop animation I add pan gesture

let pan = UIPanGestureRecognizer(
                target: self,
                action: #selector(didPan))
pan.delegate = self
view.addGestureRecognizer(pan)

Next I handle this pan

if recognizer.state == .began {
    animator.interactive = true
    navigationController!.popViewController(animated: true)
}

animator.handlePan(recognizer: recognizer)

Then inside animator conformed to UIPercentDrivenInteractiveTransition and UIViewControllerAnimatedTransitioning I do transform animation. I try to pop navigation from VC_2 to VC_1 by pan gesture.

The problem is after adding pan gesture table view is not scrolling. I think it's because 2 gesture recognizers (my own and UIKit table view's recognizer). Actually I want my own pan interactively pop my VC_2 when table is scrolled up.

The only one idea was

func gestureRecognizer(
        _ gestureRecognizer: UIGestureRecognizer,
        shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
    return tableView.contentOffset.y <= 0
}

But on pop table view offset changed strange: I mean table is scroll too much as pan gesture moved (move for 20px, offset changed for 500px some kind of that).

What is the best way to handle this? You can see such animation in Inbox app from Google - pop from e-mail to list.

Upvotes: 2

Views: 259

Answers (0)

Related Questions