Using UITapGestureRecognizer to Show / Hide Menus

I am trying to find a good way to show / hide menus, just like iBooks. To do this, I configured UITapGestureRecognizer, but, unfortunately, this means that none of the buttons on the screen work. I know I can use

tapRecognizer.cancelsTouchesInView = NO;

to allow touches to go through, but of course both things happen and I cannot cancel the show / hide menu.

Is there a way to stop UITapGestureRecognizer from playing on certain buttons or actions? Or is there a better way to do this overall?

Thanks for any help you can give me!

: - Joe

+3
source share
2 answers

- Joe, UIGestureRecognizerDelegate (i.e @interface YourViewController : UIViewController <UIGestureRecognizerDelegate>).

, UIGestureRecognizerDelegate, - (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch. , touch.view . return !([touch.view isKindOfClass:[UIButton class]]);, , , .

+5

( - ), :

NO gestureRecognizer: shouldReceiveTouch: touch.view .

+3

Source: https://habr.com/ru/post/1757496/


All Articles