Because of network issues, there's a possibility i'm calling a UIView animate function twice. Somehow that seems to mess up the finished boolean you get in the completion block.
During the animation I move a UIView off screen. At the end of the animation it should set the frame i'm animating to hidden. I notice that the finished BOOL in the completion block is always set to YES. So when I call the animation for the second time, before the first call to the animation is finished, it will set to BOOL to finished, even though i expect it to be set to NO as the animation was interrupted by a new call to that same animation.
[UIView animateWithDuration:animated ? VOTE_ANIMATION_DURATION : 0.0 delay:2 options:UIViewAnimationOptionCurveEaseOut animations:^{
self.waitingView.frame = CGRectMake(self.waitingView.frame.origin.x, (-self.waitingView.frame.size.height) - WAITINGVIEW_SHADOW_HEIGHT, self.waitingView.frame.size.width, self.waitingView.frame.size.height);
} completion:^(BOOL finished) {
if (finished) {
DDLogInfo(@"set VotingView Animation is finished");
self.waitingView.hidden = YES;
}
}];
I tried adding the following line too, but did not help.
[UIView setAnimationBeginsFromCurrentState:YES];
Any clues?
UIViewAnimationOptionBeginFromCurrentState
instead of the method call. But that is not the solution here. – Leo Natan