转自: http://blog.csdn.net/guoyuyanmen/article/details/50463764
添加长按手势如下,执行的时候会发现响应两次
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(longTapAction:)];
longPress.minimumPressDuration = 0.8; //定义按的时间
longPress.numberOfTouchesRequired = 1;
[self addGestureRecognizer:longPress];
解决办法:
- (void) longTapAction:(UILongPressGestureRecognizer *)longPress {
if (longPress.state == UIGestureRecognizerStateBegan) {
NSLog(@”long pressTap state :begin”);
}else {
NSLog(@”long pressTap state :end”);
}
}