HalfModalPresentationController icon indicating copy to clipboard operation
HalfModalPresentationController copied to clipboard

completion not called on UIView.animate on ios 10 and ios 12

Open armintelker opened this issue 7 years ago • 8 comments

the completion is not called on ios 10 and ios 12. this is strange. can you reproduce this?

HalfModalTransitionAnimator.swift

        UIView.animate(withDuration: transitionDuration(using: transitionContext), animations: {
            if self.edge == .maxYEdge {
                from.view.frame.origin.y = 800
            } else {
                from.view.alpha = 0
            }
        }, completion: { _ in
            transitionContext.completeTransition(!transitionContext.transitionWasCancelled)
        })

armintelker avatar Jul 24 '18 09:07 armintelker

@martinnormark Facing same issue here

punithbm avatar Jul 28 '18 01:07 punithbm

Noticed the same issue on my iPhone 6 (10.3.1). iOS 11 and 12 are okay.

Still looking into a proper solution but a temp workaround could be:

// HalfModalTransitionAnimator.swift
// @objc func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
if #available(iOS 11.0, *) {
    UIView.animate(withDuration: self.transitionDuration(using: transitionContext), animations: {
        from?.view.frame.origin.y = 800
    }) { _ in
        transitionContext.completeTransition(!transitionContext.transitionWasCancelled)
    }
else {
    DispatchQueue.main.asyncAfter(deadline: .now() + 0.4) {
        transitionContext.completeTransition(!transitionContext.transitionWasCancelled)
    }
}

apparition47 avatar Jul 30 '18 08:07 apparition47

@apparition47 iOS 12 also has same issue

punithbm avatar Jul 30 '18 08:07 punithbm

For whatever reason the UIPanGestureRecognizer's onPan() selector isn't receiving events and so the transition never completes and my modal is stuck.

//iOS 10 console finished transition animating... start interactive

//iOS 11 //finished transition //animating... //start interactive //animate completed //dismissal did end: true //done dismiss animation

Changing this seemed to fix my issue on iOS 10 and allow the transition to complete:

// CardModalTransitioningDelegate.swift
var interactiveDismiss = false

apparition47 avatar Jul 31 '18 02:07 apparition47

iOS 10.3 also has same issue var interactiveDismiss = false This solved my problem.

tks @apparition47

jsndev avatar Oct 06 '18 06:10 jsndev

Have found a solution on this

override func startInteractiveTransition(_ transitionContext: UIViewControllerContextTransitioning) { super.startInteractiveTransition(transitionContext) finish() }

in HalfModalInteractiveTransition.swift

pmaksimov avatar Oct 10 '18 11:10 pmaksimov

@apparition47 That doesn't solves the issue. It only makes transition non-interactive as far as I see.

pmaksimov avatar Oct 10 '18 11:10 pmaksimov

Wow great solution I was trouble with this also var interactiveDismiss = false fixed it.

parvshkhan avatar Dec 24 '18 10:12 parvshkhan