我的animationDidStop方法由于某种原因没有被调用,最初我认为这是因为代理没有设置但已经解决了我仍然遇到同样的问题。有任何想法吗?提前谢谢:)
- (void)hideInterfaceButtonClicked : (id) sender
{
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop)];
[UIView beginAnimations:@"MoveView" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
[UIView setAnimationDuration:0.5];
// Move to the right
CGAffineTransform translateInterface = CGAffineTransformMakeTranslation(454,288);
// Scale
CGAffineTransform scale = CGAffineTransformMakeScale(0.20,0.20);
// Apply them to the view
self.transform = CGAffineTransformConcat(scale, translateInterface);
self.alpha = 0.0;
[UIView commitAnimations];
}
- (void)animationDidStop {
NSLog(@"Animation Has Stopped");
[[NSNotificationCenter defaultCenter] postNotificationName:@"hiddenInteraceViewNeeded" object:self]; //after MoveView finishes
}
答案 0 :(得分:1)
您可以使用the new (iOS4+) block syntax:
来实现您的目标[UIView animateWithDuration:0.5
delay:0.0
options:UIViewAnimationCurveEaseIn
animations:^{
// Move to the right
CGAffineTransform translateInterface = CGAffineTransformMakeTranslation(454,288);
// Scale
CGAffineTransform scale = CGAffineTransformMakeScale(0.20,0.20);
// Apply them to the view
self.transform = CGAffineTransformConcat(scale, translateInterface);
self.alpha = 0.0;
} completion:^(BOOL finished) {
NSLog(@"Animation Has Stopped");
[[NSNotificationCenter defaultCenter] postNotificationName:@"hiddenInteraceViewNeeded" object:self]; //after MoveView finishes
}];