Open nico75005 opened 8 years ago
A workaround is to use a CATransaction:
CATransaction.begin()
CATransaction.setCompletionBlock( {
// code to call once the animation is over
} )
subview.hidden = false
CATransaction.commit()
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.
Fixed in #72
UIView.animateWithDuration(0.5, animations: { subview.hidden = false }, completion: { finished in // never called when changing hidden property of a subview of TZStackView })