我知道這個問題被問到很多,但我已經嘗試了所有其他答案,我無法弄清楚爲什麼動畫停止選擇器沒有被調用。下面是代碼:setAnimationDidStopSelector:沒有被調用
-(void) moveImage:(UIImageView *)image duration:(NSTimeInterval)duration curve:(int)curve x:(CGFloat)x y:(CGFloat)y annKey:(NSString *) annKey{
[UIView setAnimationDelegate:self];
[UIView setAnimationDuration:duration];
[UIView setAnimationCurve:curve];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationDidStopSelector:@selector(animationFinished:finished:context:)];
CGAffineTransform transform = CGAffineTransformMakeTranslation(x, y);
image.transform = transform;
[UIView beginAnimations:annKey context:NULL];
[UIView commitAnimations];
}
這是一個被髮送的所有正確的參數主要動畫功能。
- (void)animationFinished:(NSString *)animationID finished:(BOOL)finished context:(void *)context
{
if ([animationID isEqualToString:@"Burn"])
{
NSLog(@"Animation: %@ has finished.",animationID);
}
NSLog(@"This does not get called, why not?");
}
我的NSLogs都沒有顯示文本。我究竟做錯了什麼?
爲什麼你有兩個'beginAnimations'? – RyJ
對不起,這是一個錯誤,我已經從代碼中刪除了第一個。但問題依然存在。 – JH95
移動此行,'[UIView beginAnimations:annKey context:NULL];'移動到'moveImage:duration:curve:x:y:annKey:'方法的頂部。 – titaniumdecoy