How to disable multitouch when there are multiple views?

I created my own custom view that extends UIControl. This customizable presentation has its own sensory implementation. I implemented touchbegan, Moved, Ended and Canceled in it.

In the main view controller, I created several instances of this view. Thus, there are several user buttons on the screen.

I want to disable multitouch in my application. If I press one user button, then the other buttons should not respond.

It was actually easy to implement. While I held a few buttons, I could just add the userInteractionEnabled properties for the other buttons until it ends.

But the problem is that when I press these several buttons at the same time, two or more toucheBegan methods work at the same time, and messaging is messed up.

I tried setting multiTouchEnabled = NO and exclusiveTouch = YES, but it still does not work.

How to make disable multitouch in my application?

Thanks.

+4
source share
1 answer

You need to set exclusiveTouch to YES , not NO (by default it is). The name of the property means that the view is the exclusive recipient of any touch events for the duration.

+6
source

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


All Articles