Interactive transition strange flashes when canceled

I follow this guide to find out how I can make interactive transitions for UIViewControllers.

Everything is working fine, but I found a flicker.

The first flicker I discovered occurs when you drag the screen from right to left. This is due to the fact that the panorama gesture recognizes every drag and drop and launches the method panned(_:)and will appear or execute sega to change controllers. I set id by adding delegate method gestureRecognizerShouldBegin(_:).

This ensures that if a drag from right to left is done, the gesture never starts ( .Begin).

But now I have a different problem. If I drag from left to right (as intended), but without interrupting the drag, change the direction from right to left, the transition should be canceled. In this case, I see a brief flicker with the new controller before the old controller is presented again.

What can I do to gracefully cancel interactive animation?

This video is trying to show the problem. I could not find a way to slow this animation so fast.

EDIT

I tried with two different approaches.

This one is used CABasicAnimationto animate the transition. And this one usesanimateWithDuration(_:delay:usingSpringWithDamping:initialSpringVelocity:options:animations:completion:)

Both of them still flicker when I call cancelInteractiveTransition

+4
source share

All Articles