Reputation: 117
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!
Upvotes: 6
Views: 1184
Reputation: 1465
Your question sounds like you're not calling the animations and dispatches on the main thread. This causes unexpected behaviour, such as views not updating or moving until a certain point in time.
Please try to move the animation block inside a dispatch_main like so:
dispatch_async(dispatch_get_main_queue(), ^{
<# Code #>
});
and see if it fixes the problem.
Upvotes: 0
Reputation: 15335
The Question title and the descriptions seems to be a differ(unClear to understand), anyhow if you want to to produce the task after sometime then look at below
dispatch_after and [UIView animation: duration] happen immediately
This could work :
// Do your stuff OR animations then use below for DISPATCH_AFTER...
double delayInSeconds = 2.0f;
dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
// Do your Stuff Or Add Animation
[UIView animateWithDuration:.6f animations:^{
self.tableView.contentOffset = CGPointMake(0, 173);
}];
});
Upvotes: 0
Reputation: 5892
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.
Upvotes: 1