我有一个图像类型的对象,我正在使用uipangestrerecognizer移动它,当对象到达某一帧时,我需要停止识别uipangestrerecognizer。
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具有已启用的属性。文档:
禁用手势识别器,使其不接收触摸。这个
默认值为“是”。如果您将此属性更改为“否”
手势识别器当前正在识别一个手势
识别器转换到取消状态。
编辑:
只需将enabled属性设置为no。
gestureRecognizer.enabled = NO;