UIScrollViewにUIImageViewを配置しました。基本的に、このUIImageViewは非常に大きなマップを保持し、「矢印」がナビゲーション方向を指す事前定義されたパス上にアニメーションを作成しました。
しかし、uiscrolleventsが発生するたびに、MainLoopがフリーズし、NSTimerが起動されず、アニメーションが停止したと思います。
UIScrollView、CAKeyFrameAnimation、またはNSTimerに、この問題を解決する既存のプロパティはありますか?
//viewDidLoad
self.myTimer = [NSTimer scheduledTimerWithTimeInterval:0.05 target:self selector:@selector(drawLines:) userInfo:nil repeats:YES];
- (void)drawLines:(NSTimer *)timer {
CALayer *arrow = [CALayer layer];
arrow.bounds = CGRectMake(0, 0, 5, 5);
arrow.position = CGPointMake(line.x1, line.y1);
arrow.contents = (id)([UIImage imageNamed:@"arrow.png"].CGImage);
[self.contentView.layer addSublayer:arrow];
CAKeyframeAnimation* animation = [CAKeyframeAnimation animation];
animation.path = path;
animation.duration = 1.0;
animation.rotationMode = kCAAnimationRotateAuto; // object auto rotates to follow the path
animation.repeatCount = 1;
animation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
animation.fillMode = kCAFillModeForwards;
[arrow addAnimation:animation forKey:@"position"];
}