简体   繁体   中英

Prevent UIButton touch event for multitouch

after finding out that there is a bug in the UITapGestureRecognizer ( How to cancel button tap if UIGestureRecognizer fires? ) I am thinking about detecting two finger taps and two finger double-taps in the touchesEnded method of my view controller.

Here is the situation, what I want to do and my problem:

Situaion: I have a UIView, managed by a UIViewController. This view contains multiple UIButtons that react to taps.

What I want: I want to react to two finger taps and to two finger double-taps on my view but also to one finger taps on the UIButtons.

Problem: Once a button is tapped (even if using two fingers on the view) the touchesEnded method on my view controller isn't called anymore. How can I cancel button taps when more than one finger is used?

I already tried to subclass UIView and use the hitTest method, but the touches property of the event is always empty in this. Also I tried to overlay the buttons with a transparent UIView, but this also cancels the button touches.

@Mark I was trying to get your example from the other day working. As it is a bug, I altered it to use a tap recognizer. It's not a true solution as you don't get a clicked effect on the button but the right button messages the Touch Up Inside event. You can check out those changes here . See if it helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM