NSTimer не запускается при возникновении события uiscrollview

У меня есть UIImageView, помещенный в UIScrollView, в основном этот 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"];
}
15
задан ubaltaci 1 February 2012 в 04:08
поделиться