I have an intermittent issue where I move a UIImageView around the screen using CAKeyframeAnimation. I want the UIImageView position to stay where the animation ends when it runs. This error occurs only for certain start and end points. When I use random points, it works correctly most of the time, but in about 5-15% of cases when it fails, it returns to the position of preliminary animation. The problem only occurs when using CAKeyframeAnimation using the path property. If I use the values property, the error does not appear. I set removeOnCompletion = NO, and fillMode = kCAFillModeForwards. I posted a link to the test Xcode below. Here is my code for tweaking the animation. I have a usePath property. When it is YES, an error appears.When I set usePath to NO, a binding error does not occur. In this case, I use a path that is a simple string, but as soon as I resolve this error with a simple path, I will use a more complex path with curves in it.
CAKeyframeAnimation *moveAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
if (self.usePath) {
CGMutablePathRef path = CGPathCreateMutable();
CGPathMoveToPoint(path, NULL, startPt.x, startPt.y);
CGPathAddLineToPoint(path, NULL, endPt.x, endPt.y);
moveAnimation.path = path;
CGPathRelease(path);
} else {
moveAnimation.values = [NSArray arrayWithObjects:
[NSValue valueWithCGPoint:startPt],
[NSValue valueWithCGPoint:endPt],
nil];
}
moveAnimation.calculationMode = kCAAnimationPaced;
moveAnimation.duration = 0.5f;
moveAnimation.removedOnCompletion = NO;
moveAnimation.fillMode = kCAFillModeForwards;
moveAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut];
[ball.layer addAnimation:moveAnimation forKey:@"moveAnimation"];
dl goto (http://www.24x7digital.com/downloads/PathFillModeBug.zip)
" ", . , - . , usePath YES NO. usePath - , . usePath , .
SDK 3.1.3, , SDK 3.0, Sim iPhone.
, , - , . , .