Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dispatch_after and [UIView animation: duration] happen immediately (but shouldn't)

With iOS7, we are getting an intermittent bug. It didn't happen with iOS6.

It doesn't start right away, but ~30sec to ~2 min into the game, ALL of the animations, and the dispatch_after commands happen instantaneously.

To be more specific, the animations are happening as if the "duration:" value is 0, even though it is definitely not 0. To be more specific, the dispatch_after is happening as if the wait = 0.

Once it starts, it persists until the software is terminated.

I have no idea how to debug this, or if it is an iOS7 bug. Any thoughs/help would be greatly appreciated!

like image 859
samuel Schweighart Avatar asked Oct 01 '13 00:10

samuel Schweighart


1 Answers

Is the problem that you believe your completion block is being called prematurely?

If so, have you checked the value of the Boolean value passed into the completion block? You may want to only execute the statements in that block if the Boolean value is true.

e.g.

[UIView animateWithDuration... animations:^{
    //do something
} completion:^(BOOL finished) {
    if (finished) {
        // do something
    }
}];

I saw this when the completion block was being called before the animation had even started, but it was actually because something else had cancelled the animation, hence finished = NO.

This doesn't answer the question regarding dispatch_after, so you may still be experiencing a bug there.

like image 52
Sam Avatar answered Oct 13 '22 01:10

Sam