Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gestureRecognizer: shouldReceiveTouch: not getting called

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;
}

Press and hold method is still being called even though i set the bool to no.

like image 407
iamruskie Avatar asked Oct 13 '12 02:10

iamruskie


1 Answers

Seems like you haven't set the delegate ?

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

Is the part of UIGestureRecognizerDelegate. So you should have set the delegate too.

touchHold.delegate = self;

Edit: You should tell your view controller to implement the UIGestureRecognizerDelegate. Something like

@interface YourViewController <UIGestureRecognizerDelegate>
like image 112
ewiinnnnn Avatar answered Oct 06 '22 00:10

ewiinnnnn