Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completion closure never called when animating showing/hiding #70

Open
nico75005 opened this issue Feb 25, 2016 · 3 comments · May be fixed by #72
Open

Completion closure never called when animating showing/hiding #70

nico75005 opened this issue Feb 25, 2016 · 3 comments · May be fixed by #72

Comments

@nico75005
Copy link

UIView.animateWithDuration(0.5, animations: {
subview.hidden = false
}, completion: { finished in
// never called when changing hidden property of a subview of TZStackView
})

@nico75005
Copy link
Author

A workaround is to use a CATransaction:

CATransaction.begin()

CATransaction.setCompletionBlock( {
    // code to call once the animation is over
} )

subview.hidden = false

CATransaction.commit()

@EliaCereda
Copy link

I’ve encountered this problem too, nice workaround! Is the completion block never called in your experience? In my case it works the first time, but not on subsequent calls.

I suspect the cause is this line in the code of TZStackView.observeValueForKeyPath(…):

UIView.setAnimationDelegate(self)

It’s just a guess, but I think UIView implements the completion callback by setting some internal object as the delegate of the animation. Which then brings the question, does calling UIView.setAnimationDelegate inside a CATransaction result in the correct behavior? Could you do a quick test and see if TZStackView.hiddenAnimationStopped is called in your code?

EDIT: it seems issue #50 is referring to the same problem, this definitely needs to be looked into. Unfortunately it’s going to be a while before I’m able to do it myself, but I will if it hasn’t been fixed yet.

CosynPa added a commit to CosynPa/TZStackView that referenced this issue Mar 5, 2016
…ixing tomvanzummeren#70 (Completion closure never called when animating showing/hiding) and tomvanzummeren#50 (Setting TZStackView to hidden inside animateAlongsideCoordinator's animation block causes strange behavior)
@CosynPa CosynPa linked a pull request Mar 5, 2016 that will close this issue
@CosynPa
Copy link

CosynPa commented Mar 5, 2016

Fixed in #72

CosynPa added a commit to CosynPa/TZStackView that referenced this issue Mar 5, 2016
…xing tomvanzummeren#70 (Completion closure never called when animating showing/hiding) and tomvanzummeren#50 (Setting TZStackView to hidden inside animateAlongsideCoordinator's animation block causes strange behavior)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants