Keith
Keith

Reputation: 111

action sequence (objective C) iPhone

I'm having a issue figuring out how to do make sequential actions occur.

Broken down to its simplest form what I'm trying to do is make image1 grow 25% larger and only upon completion of this action will a sound play.

I can make the image grow, I can make the sound play, no problem, but I cannot figure out how to make the sound play ONLY after the image has grown it's 25 percent.

Any help would be great.

Thanks.

Upvotes: 2

Views: 349

Answers (2)

bryanmac
bryanmac

Reputation: 39296

Are you are using an animation to resize the image/view? If so you

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.0f];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(resizeFinished:finished:context:)];
// Resize the view/image here
[UIView commitAnimations];

and then in the selector you can play the sound

- (void)resizeFinished:(NSString *)animationID finished:(BOOL)finished context:(void *)context;
{
    // Play the sound here
}

You can also implement the callback delegate

- (void)animationDidStop:(CAAnimation *)theAnimation finished:(BOOL)flag

Upvotes: 1

Jordão
Jordão

Reputation: 56477

If you use core animation, you can run your continuation logic in a completion block (iOS 4). Or you can register a callback on setAnimationDidStopSelector. Take a look here for details.

Upvotes: 0

Related Questions