【问题标题】:After Completion of Animation want to call some methods动画完成后想调用一些方法
【发布时间】:2012-01-05 10:45:34
【问题描述】:
在我的 iPhone 应用程序中
我正在制作某些动画。
喜欢
[UIView beginAnimations:@"stalk" context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationBeginsFromCurrentState:YES];
self.frame=originalSelf;
[UIView commitAnimations];
这个动画完成后我想调用一些方法...
我知道一些关于块动画或
DidStopAnimation 通知
我该怎么做....
谢谢..
【问题讨论】:
标签:
iphone
objective-c
xcode
cocoa-touch
animation
【解决方案1】:
在 iOS 4 及更高版本上,建议为此使用块:
[UIView animateWithDuration:1
animations:^{
self.frame=originalSelf;}
completion:^(BOOL finished){
//My method call;
}
];
【解决方案2】:
尝试使用
[UIView beginAnimations:@"stalk" context:nil];
[UIView setAnimationDuration:1];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(afterAnimationStops)]
self.frame=originalSelf;
[UIView commitAnimations];
然后你就可以实现方法了
-(void)afterAnimationStops{
}