gpt4 book ai didi

iPhone - 3次多次检测到UIGestureRecognizer

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:33:03 25 4
gpt4 key购买 nike

我有 3 个 UIGestureRecognizers 附加到一个 View :一个手指双击,两个手指双击和一个手指三次点击。问题是这样的:当我三次点击时,它触发了应该通过双击触发的方法,然后是三次点击的方法。

我是这样添加的。

// one finger double tap
doubleTap = [[[UITapGestureRecognizer alloc]
initWithTarget:self
action:@selector(handleDoubleTap:)] autorelease];
[doubleTap setCancelsTouchesInView:YES];
[doubleTap setNumberOfTapsRequired:2];
[doubleTapDoisDedos setNumberOfTouchesRequired:1];
[doubleTap setDelegate:self];
[[[CCDirector sharedDirector] openGLView] addGestureRecognizer:doubleTap];


// two fingers double tap
twoFingerDoubleTap = [[[UITapGestureRecognizer alloc]
initWithTarget:self
action:@selector(handleDoubleTapTwoFingers:)] autorelease];
[twoFingerDoubleTap setCancelsTouchesInView:YES];
[twoFingerDoubleTap setNumberOfTapsRequired:2];
[twoFingerDoubleTap setNumberOfTouchesRequired:2];
[twoFingerDoubleTap setDelegate:self];
[[[CCDirector sharedDirector] openGLView] addGestureRecognizer:twoFingerDoubleTap];



// triple tap com um dedo faz as cartas se empilharem
tripleTapOneFinger = [[[UITapGestureRecognizer alloc]
initWithTarget:self
action:@selector(handleTripleTap:)] autorelease];
[tripleTapOneFinger setCancelsTouchesInView:YES];
[tripleTapOneFinger setNumberOfTapsRequired:3];
[tripleTapOneFinger setNumberOfTouchesRequired:1];
[tripleTapOneFinger setDelegate:self];
[[[CCDirector sharedDirector] openGLView] addGestureRecognizer:tripleTapOneFinger];

是的,我尝试添加这些,但没有成功

[doubleTap requireGestureRecognizerToFail:doubleTapTwoFingers];   
[doubleTap requireGestureRecognizerToFail:tripleTapOneFinger];

[doubleTapTwoFingers requireGestureRecognizerToFail:doubleTap];
[doubleTapTwoFingers requireGestureRecognizerToFail:tripleTapOneFinger];

[tripleTapOneFinger requireGestureRecognizerToFail:doubleTap];
[tripleTapOneFinger requireGestureRecognizerToFail:doubleTapTwoFingers];

我错过了什么?

有没有办法在 handle 方法中检测点击次数?

谢谢

最佳答案

通过 requireGestureRecognizerToFail: 添加过多的手势识别器依赖项会导致问题。在您的情况下,只需添加所需的一个依赖项:

[doubleTap requireGestureRecognizerToFail:tripleTapOneFinger]; 

关于iPhone - 3次多次检测到UIGestureRecognizer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9243868/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com