gpt4 book ai didi

iphone - 手势识别器 : shouldReceiveTouch: not getting called

转载 作者:太空狗 更新时间:2023-10-30 03:30:16 24 4
gpt4 key购买 nike

gestureRecognizer:shouldReceive Touch: 方法未被调用。我设置不当吗?

-(id) init 
{
UILongPressGestureRecognizer *touchHold = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleTouchHold:)];
touchHold.minimumPressDuration = 1.0f;
touchHold.numberOfTouchesRequired = 1;
[[CCDirector sharedDirector].openGLView addGestureRecognizer:touchHold];
}

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
return NO;
}

即使我将 bool 设置为 no,仍会调用按住方法。

最佳答案

好像你还没有设置 delegate ?

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch

是UIGestureRecognizerDelegate的一部分。所以你也应该设置委托(delegate)。

touchHold.delegate = self;

编辑:你应该告诉你的 View Controller 实现 UIGestureRecognizerDelegate。有点像

@interface YourViewController <UIGestureRecognizerDelegate>

关于iphone - 手势识别器 : shouldReceiveTouch: not getting called,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12869541/

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