我正在使用以下代码在 iPad 中发生 swipeEvent 时旋转视图(使用 UISwipeGestureRecognizer)。但是当我连续执行 Swipe(2 或 3)时,没有调用该方法,我知道原因,我在该方法中使用了 Duration对于 CABasicAnimation。我怎样才能克服这个问题?请问有什么帮助吗?
-(void)handleSwipeFromD:(UISwipeGestureRecognizer *)recognizer
{
NSLog(@"down");
if (operationStart)
{
self.commonLayer = [self.layer presentationLayer];
self.layer.transform = commonLayer.transform;
[self.commonLayer removeAnimationForKey:@"rotationAnimate"];
self.commonLayer = self.layer;
rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
rotationAnimation.fromValue = [NSNumber numberWithFloat:0.0 * M_PI];
rotationAnimation.toValue = [NSNumber numberWithFloat:2.0 * M_PI];
//rotationAnimation.toValue = [NSNumber numberWithFloat: 2.5 * 3.15 ];
rotationAnimation.duration = 1.0;
rotationAnimation.cumulative = YES;
rotationAnimation.repeatCount = 1.0;
//rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
[self.commonLayer addAnimation:rotationAnimation forKey:@"rotationAnimate"];
}
}