UIPangestureRecognizer

UIPangestureRecognizer

本文介绍了当对象移动到某个帧时,如何停止UIPanGestureRecognizer的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个图像类型的对象,我正在使用UIPanGestureRecognizer移动,当对象到达某个帧时我需要停止识别UIPanGestureRecognizer。

I have an object of image type which I am moving using UIPanGestureRecognizer, and I need to stop recognizing the UIPanGestureRecognizer when the object reaches a certain frame.

    UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(move:)];
    [panRecognizer setMinimumNumberOfTouches:1];
    [panRecognizer setMaximumNumberOfTouches:1];
    [panRecognizer setDelegate:self];
    [templatePhotoPlaceholderView addGestureRecognizer:panRecognizer];

-(void)move:(UIPanGestureRecognizer *)gestureRecognizer
{
    CGPoint translatedPoint = [gestureRecognizer translationInView:templatePhotoPlaceholderView];

    if([gestureRecognizer state] == UIGestureRecognizerStateBegan) {
        _firstX = [imageview center].x;
        _firstY = [imageview center].y;
    }



    translatedPoint = CGPointMake(_firstX+translatedPoint.x, _firstY+translatedPoint.y);
    //NSLog(@" Move center point :%@", NSStringFromCGPoint(translatedPoint));

    [imageview setCenter:translatedPoint];

}

我该怎么做?

推荐答案

UIGestureRecognizers具有启用的属性。文档:

UIGestureRecognizers have an enabled property. Documentation:

编辑:

只需将启用的属性设置为NO。

Just set the enabled property to NO.

gestureRecognizer.enabled = NO;

这篇关于当对象移动到某个帧时,如何停止UIPanGestureRecognizer的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 13:50