Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

After Completion of Animation want to call some methods

In my iPhone application

I am doing certain animations. like

[UIView beginAnimations:@"stalk" context:nil];
    [UIView setAnimationDuration:1];
    [UIView setAnimationBeginsFromCurrentState:YES];
    self.frame=originalSelf;
    [UIView commitAnimations];

After completion of this animation I want tocall some methods...

I know something abt block animations or

DidStopAnimation notification

How do I do that.... Thanks..

like image 741
Arpit B Parekh Avatar asked Jan 05 '12 10:01

Arpit B Parekh


2 Answers

On iOS 4 and later, using blocks is recommended for this purpose:

[UIView animateWithDuration:1 
                     animations:^{
                         self.frame=originalSelf;} 
                     completion:^(BOOL finished){

                        //My method call;
                     }
     ];
like image 61
0x90 Avatar answered Sep 20 '22 13:09

0x90


Try using

[UIView beginAnimations:@"stalk" context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(afterAnimationStops)]
self.frame=originalSelf;
[UIView commitAnimations];

And then you can implement method

-(void)afterAnimationStops{

}
like image 32
Soni Avatar answered Sep 19 '22 13:09

Soni