我有一个包含UITapGestureRecognizer的UIView,它触发了一个名为handleLeftTap
的方法。
-(void)handleLeftTap {
self.player.direction = LEFT;
if(!self.isAnimating && self.toTile.isWalkable) {
for(UIView *currentView in self.subviews) {
CABasicAnimation *moveAnimation = [CABasicAnimation animationWithKeyPath:@"position"];
[moveAnimation setDuration:MOVE_ANIMATION_DURATION];
[moveAnimation setDelegate:self];
[moveAnimation setRemovedOnCompletion:NO];
[moveAnimation setFillMode:kCAFillModeForwards];
moveAnimation.toValue = [NSValue valueWithCGPoint:CGPointMake(currentView.center.x+TILE_WIDTH, currentView.center.y)];
[currentView.layer addAnimation:moveAnimation forKey:nil];
}
NSLog(@"animated\n");
}
}
当我第一次点击屏幕时,这个动画效果很好;每个子视图都向右移动了TILE_WIDTH
像素。但是,如果我再次点击屏幕,动画根本不起作用;没有视图移动。我使用断点遍历了这段代码,并验证了该动画是否已添加到层中。只是动画没有被应用,或者类似的东西。有没有办法解决这个问题?
发布于 2013-04-24 09:09:15
不太确定,但您确定第二个动画的位置与第一个动画之后的位置不同吗?
https://stackoverflow.com/questions/16181606
复制相似问题