由於某種原因,我必須再次提交相同的動畫。動畫重複
- (void)startAnimation {
NSLog(@"startAnimation called:shouldContinue = %u",shouldContinue);
shouldContinue = YES;
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:3];
[UIView setAnimationRepeatCount:10];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop: finished: context:)];
// bulabula...
[UIView commitAnimations];
}
- (void)cancelAnimation {
shouldContinue = NO;
}
- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
NSLog(@"animationDidStop called:shouldContinue = %u",shouldContinue);
if (shouldContinue) {
[self startAnimation];
}
}
但結果是,「稱爲startAnimation:shouldContinue = 1」的文本被一次又一次地迅速打印後cancelAnimation是called.It前一輪好像同時(YES){打印(,,, ); }一個死循環heppens。