iOS 长按手势执行两次解决办法

来源:互联网 发布:公司网络无法玩游戏 编辑:程序博客网 时间:2024/06/05 09:56

添加长按手势如下,执行的时候会发现响应两次
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”);
}

}

0 0
原创粉丝点击