我已经搜索了很多苹果的参考资料,但仍然无法解决我的问题.
我拥有的:
- 连接有2个
UIImageView
和2个UIButton
的屏幕 - 2 kinds of animation:
- 放大和缩小每个图像,一个接一个,每
viewDidLoad
个图像中只有一个 - 当按下一个按钮(一个自定义按钮隐藏在每
UIImageView
个按钮的"内部")时,它会触发相应UIImageView
的动画–只有一个,而不是两个–同时放大,然后缩小. - 当我为IOS4+写作时,我被告知要使用基于挡路的动画!
- 放大和缩小每个图像,一个接一个,每
我需要的是:
如何取消正在运行的动画?我已经设法取消了,除了最后一次.:/
以下是我的代码片段:
[UIImageView animateWithDuration:2.0
delay:0.1
options:UIViewAnimationOptionAllowUserInteraction
animations:^{
isAnimating = YES;
self.bigLetter.transform = CGAffineTransformScale(self.bigLetter.transform, 2.0, 2.0);
} completion:^(BOOL finished){
if(! finished) return;
[UIImageView animateWithDuration:2.0
delay:0.0
options:UIViewAnimationOptionAllowUserInteraction
animations:^{
self.bigLetter.transform = CGAffineTransformScale(self.bigLetter.transform, 0.5, 0.5);
} completion:^(BOOL finished){
if(! finished) return;
[UIImageView animateWithDuration:2.0
delay:0.0
options:UIViewAnimationOptionAllowUserInteraction
animations:^{
self.smallLetter.transform = CGAffineTransformScale(self.smallLetter.transform, 2.0, 2.0);
} completion:^(BOOL finished){
if(! finished) return;
[UIImageView animateWithDuration:2.0
delay:0.0
options:UIViewAnimationOptionAllowUserInteraction
animations:^{
self.smallLetter.transform = CGAffineTransformScale(self.smallLetter.transform, 0.5, 0.5);
}
completion:^(BOOL finished){
if (!finished) return;
//block letter buttons
[self.bigLetterButton setUserInteractionEnabled:YES];
[self.smallLetterButton setUserInteractionEnabled:YES];
//NSLog(@"vieDidLoad animations finished");
}];
}];
}];
}];
不知何故,smallLetter
UIImageView
不能正常工作,因为当按下(通过按钮)bigLetter
时,它会正常取消动画...
EDIT:
我已经使用了这个解决方案,但是在缩小smallLetter
UIImageView
的时候仍然有问题-根本没有取消…
solution个
EDIT2:我在Next/Prev方法的开头添加了以下内容:
- (void)stopAnimation:(UIImageView*)source {
[UIView animateWithDuration:0.01
delay:0.0
options:(UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionAllowUserInteraction)
animations:^ {
source.transform = CGAffineTransformIdentity;
}
completion:NULL
];
}
问题依然存在……:/不知道如何中断动画链中字母的最后一个动画