本文介绍了gestureRecognizer:shouldReceiveTouch:没有被调用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
gestureRecognizer:shouldReceiveTouch:方法未被调用。我是否设置不正确?
gestureRecognizer:shouldReceiveTouch: method isnt being called. Have i set it up improperly?
-(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,仍然会调用按住方法。
Press and hold method is still being called even though i set the bool to no.
推荐答案
好像你还没有设置代理?
Seems like you haven't set the delegate ?
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
是UIGestureRecognizerDelegate的一部分。所以你也应该设置委托。
Is the part of UIGestureRecognizerDelegate. So you should have set the delegate too.
touchHold.delegate = self;
编辑:
您应该告诉您的视图控制器实现UIGestureRecognizerDelegate。类似
You should tell your view controller to implement the UIGestureRecognizerDelegate. Something like
@interface YourViewController <UIGestureRecognizerDelegate>
这篇关于gestureRecognizer:shouldReceiveTouch:没有被调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!