I have a thread which performs some tasks.
At the end I want to run a selector to hide an image with animation.
[self performSelectorOnMainThread:@selector(finishUpdate) withObject:nil waitUntilDone:YES];
I am setting the duration to 10 seconds:
- (void) finishUpdate {
UIImageView *myImage = (UIImageView *)[self.view viewWithTag:788];
CGContextRef context = UIGraphicsGetCurrentContext();
[UIView beginAnimations:nil context:context];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:10.0f];
myImage.frame = CGRectMake(0, 200, 320, 80);
myImage.alpha = 0.0f;
[UIView commitAnimations];
}
But it is disappearing instantly and the thread continues immediately.
Do you know how to make my thread to wait or how to display this simple animation?
Instead of waiting for the selector to finish, I used
sleepForTimeInterval:method to pause my thread, using the same duration as my animation.