HalfModalPresentationController
HalfModalPresentationController copied to clipboard
completion not called on UIView.animate on ios 10 and ios 12
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)
})
@martinnormark Facing same issue here
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 iOS 12 also has same issue
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
iOS 10.3 also has same issue
var interactiveDismiss = false
This solved my problem.
tks @apparition47
Have found a solution on this
override func startInteractiveTransition(_ transitionContext: UIViewControllerContextTransitioning) {
super.startInteractiveTransition(transitionContext)
finish()
}
in HalfModalInteractiveTransition.swift
@apparition47 That doesn't solves the issue. It only makes transition non-interactive as far as I see.
Wow great solution I was trouble with this also var interactiveDismiss = false fixed it.