Objective C - How to change the content of an Image View after an animation

Asked

Viewed 38 times

0

I implemented an animation in a Image View and would like to know how I change your image exactly after the end of the animation.

Example:

- (IBAction)play:(id)sender {
    //ANIM . . .
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:1]; //TEM DURAÇÃO DE 1 SEGUNDO . . .
    [UIView setAnimationBeginsFromCurrentState:TRUE];
    self.objeto.frame = CGRectMake(95, 100, 62, 62); //OBJETO É UMA IMAGE VIEW . . .
    [UIView commitAnimations];

    //NESTE CASO, MUDAR IMAGEM APÓS 1 SEGUNDO . . .
}  

1 answer

1


According to Apple’s documentation, from iOS 4 you can use animations using blocks.

Using block animations you can perform as follows:

[UIView animateWithDuration:duração animations:^{
   //Código para realizar as animações
} completion:^(BOOL finished) {
    //Código que será chamado após as animações
}];

Now, using Begin/commit, which is how you are currently doing, you can add a method that it will call upon completion of the animation. Recalling that it is necessary to define the delegate so that this method is called at the end.

[UIView setAnimationDidStopSelector:@selector(finalizouAnimacao)];
[UIView setAnimationDelegate:self];

I recommend you take a look at the Apple documentation that talks about animations and also this Soen response that shows some arguments of why use block animation.

Apple Documentation - Animations

Shy should I use the block-based Animation rather than Begin/commit Animation

Browser other questions tagged

You are not signed in. Login or sign up in order to post.