GestureRecognizer: shouldReceiveTouch: not receive a call

gestureRecognizer: shouldReceiveTouch: method is not called. Did I install it incorrectly?

-(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 the method that is still being called, although I set bool to no.

+8
objective-c iphone xcode
source share
1 answer

Looks like you didn’t ask a delegate?

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

It is part of the UIGestureRecognizerDelegate. Therefore, you must also set a delegate.

 touchHold.delegate = self; 

Edit: You must tell the controller your view of the implementation of UIGestureRecognizerDelegate. Something like

 @interface YourViewController <UIGestureRecognizerDelegate> 
+26
source share

All Articles