Skip to content
This repository has been archived by the owner on Aug 25, 2020. It is now read-only.

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

Open
armintelker opened this issue Jul 24, 2018 · 8 comments
Open

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

armintelker opened this issue Jul 24, 2018 · 8 comments

Comments

@armintelker
Copy link

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)
        })
@punithbm
Copy link

@martinnormark Facing same issue here

@apparition47
Copy link

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)
    }
}

@punithbm
Copy link

@apparition47 iOS 12 also has same issue

@apparition47
Copy link

apparition47 commented Jul 31, 2018

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

@jsndev
Copy link

jsndev commented Oct 6, 2018

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

tks @apparition47

@pmaksimov
Copy link

pmaksimov commented Oct 10, 2018

Have found a solution on this

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

in HalfModalInteractiveTransition.swift

@pmaksimov
Copy link

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

@parvshkhan
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants