完成动画后想要调用一些方法

Arp*_*ekh 6 iphone xcode animation cocoa-touch objective-c

在我的iPhone应用程序中

我正在做某些动画.喜欢

[UIView beginAnimations:@"stalk" context:nil];
    [UIView setAnimationDuration:1];
    [UIView setAnimationBeginsFromCurrentState:YES];
    self.frame=originalSelf;
    [UIView commitAnimations];
Run Code Online (Sandbox Code Playgroud)

完成这个动画后我想要调用一些方法......

我知道一些阻止动画或

DidStopAnimation通知

我该怎么做....谢谢..

0x9*_*x90 11

在iOS 4及更高版本中,建议使用块来实现此目的:

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

                        //My method call;
                     }
     ];
Run Code Online (Sandbox Code Playgroud)


Son*_*oni 5

尝试使用

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

然后你可以实现方法

-(void)afterAnimationStops{

}
Run Code Online (Sandbox Code Playgroud)