相关疑难解决方法(0)

当uiscrollview事件发生时,NSTimer不会被触发

我在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"];
}
Run Code Online (Sandbox Code Playgroud)

uiscrollview nstimer cakeyframeanimation ios

15
推荐指数
1
解决办法
3739
查看次数

标签 统计

cakeyframeanimation ×1

ios ×1

nstimer ×1

uiscrollview ×1