How do you stop the UITapGestureRecognizer from catching EVERY tap?

Hello, I have an opengl view and I have a tab bar. I use a tap recognizer to use various 3D objects on the screen. I have a button on the tab bar, but it doesnโ€™t work, because the recognition tap also uses these taps. How to stop it? I have already tried this:

- (BOOL) gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch { if ([touch.view isKindOfClass:[UIBarButtonItem class]]) return FALSE; return TRUE; } 

I think that I am somehow comparing the incorrect classification, because when I debug it always returns TRUE.

+26
objective-c iphone button conflict uigesturerecognizer
Feb 03 2018-11-11T00:
source share
2 answers
   if ([touch.view.superview isKindOfClass: [UIToolbar class]]) return FALSE;

This is how I earned it. The supervisor is UIToolbar, maybe UIBarButtonIttem is a view .

+27
Feb 03 '11 at 12:29
source share

Or you can just do [singleTap setCancelsTouchesInView:NO] . Example:

 UITapGestureRecognizer *singleTap = [ [UITapGestureRecognizer alloc] initWithTarget: self action: @selector(yourSelector:) ]; [singleTap setCancelsTouchesInView:NO]; [[self view] addGestureRecognizer: singleTap]; 
+32
Jul 10 2018-12-18T00:
source share



All Articles