Iphone 动画重复
出于某种原因,我不得不再次提交相同的动画Iphone 动画重复,iphone,objective-c,animation,uiview,Iphone,Objective C,Animation,Uiview,出于某种原因,我不得不再次提交相同的动画 - (void)startAnimation { NSLog(@"startAnimation called:shouldContinue = %u",shouldContinue); shouldContinue = YES; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:3]; [UIView setAnimatio
- (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];
}
}
但结果是,在调用cancelAnimation之前,文本“startAnimation called:shouldContinue=1”在一轮之后被一次又一次地快速打印。这似乎是(YES){print(,,,;}一个死循环heppens。请指定该代码
- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{
NSLog(@"animationDidStop called:shouldContinue = %u",shouldContinue);
if (shouldContinue!=NO) {
[self startAnimation];
}
}
如果没有,请确保继续ivar
如果您确定shouldContinue为ivar,请确保指定
self.shouldContinue = NO;
您没有在任何地方调用cancelanimation函数,如果没有,那么在StartAnimation specity的末尾
self.shouldContinue = NO;
请指定该代码
- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context
{
NSLog(@"animationDidStop called:shouldContinue = %u",shouldContinue);
if (shouldContinue!=NO) {
[self startAnimation];
}
}
如果没有,请确保继续ivar
如果您确定shouldContinue为ivar,请确保指定
self.shouldContinue = NO;
您没有在任何地方调用cancelanimation函数,如果没有,那么在StartAnimation specity的末尾
self.shouldContinue = NO;
从动画代码中删除此行。。 [UIView委员会];
它将重复动画…从动画代码中删除这一行。。 [UIView委员会]; 它将重复动画