我有一个 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
像素。但是,如果我再次点击屏幕,动画根本不起作用;没有视图移动。我用断点单步执行了这段代码,并验证了这个动画是否被添加到图层中。只是没有应用动画或类似的东西。有没有办法来解决这个问题?