动画中的IOS的UIImageView叩击手势不工作(ios uiimageview tap ges

2019-10-17 04:57发布

我有一个UIImageView是动画和接收UITapGestureRecognizer 。 问题是动画的同时,敲击手势区域不与视图中移动。 我可以点击视图的原始位置和点击手势被识别。 任何人都知道如何有水龙头的认可,而鉴于移动,而不是在原来的位置?

编辑1:这是我如何设置我的双击手势识别:

UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(viewTapped:)];
    tapRecognizer.cancelsTouchesInView = YES;
    tapRecognizer.numberOfTapsRequired = 1;
    tapRecognizer.delegate = (id)self;
    [imageView addGestureRecognizer:tapRecognizer];
    imageView.userInteractionEnabled = YES;

有没有办法有手势识别跟着我认为它的道路上,因为我的动画持续几秒钟? 我错过了设置?

编辑2:这是我的代码来设置我的动画:

    double width = backgroundImageView.frame.size.width;
    double height = backgroundImageView.frame.size.height;

    CGMutablePathRef path = CGPathCreateMutable();
    double startX = -imageView.frame.size.width;
    double startY = height/4;
    double endX = 3*width;
    double endY = 0;
    double duration = 40;
    CGPathMoveToPoint(path, NULL, startX, startY);
    CGPathAddLineToPoint(path, NULL, endX, endY);
    CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
    animation.duration = duration;
    animation.path = path;
    animation.repeatCount = HUGE_VALF;
    [imageView.layer addAnimation:animation forKey:@"theAnimation"];

Answer 1:

任何有兴趣,我解决我的问题。 只需使用NSTimer ,检查和更新UIImageViewframe从表示layer由:

CGRect viewLocation = [[[imageView layer] presentationLayer] frame];    
imageView.frame = CGRectMake(viewLocation.origin.x, viewLocation.origin.y, viewLocation.size.width, viewLocation.size.height);

在此之后,触摸任何地方工作,我的形象的看法是:-)



文章来源: ios uiimageview tap gesture not working during animation