views:

21

answers:

1

Hi

I wan't to perform an animation before quitting a view. The problem is that if I write this code:

[self animationMethod];
[self removeFromSuperview];

the animation is not presented because the removeFromSuperview instruction is immediatly executed, i suppose.

There's a way to specify thath the removeFromSuperview method must be executed after a a specified time? thanks.

A: 

Does animationMethod use a [UIView beginAnimations: context:] section? If that's the case, you should use the animation delegate. Specifically:

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(removeFromSuperview)];
//Your animation stuff
[UIView commitAnimations];

Otherwise, if you're doing something else that doesn't have a callback, you can call the method after a delay using:

[self performSelector:@selector(removeFromSuperview) withObject:nil afterDelay:0.25f];

where 0.25f is the delay you want to use. I chose 0.25 because that is the default animation length for animation blocks (as shown above).

Ed Marty
I ve arredi triade with setAnimationDidStopSelector but did not work. I followed the debugger and the metodo specified as parameter isn t calle d.
Luca
All works now.....With the setAnimationDelegate:self all seems to work well! thanks a lot!!
Luca