pnmn
pnmn

Reputation: 1117

How to disable multitouch when having several views?

I created my own custom view that extends UIControl. This custom view has its own touch implementation. I implemented touchesBegan, Moved, Ended, and Canceled methods in it.

In the main view controller, I created several instances of this view. So in the screen, there are a number of custom buttons.

I want to disable multitouch in my app. If I click one custom button, then other buttons shouldn't respond.

Actually, it was easy to implement this. While I held some buttons, I could just make other buttons' userInteractionEnabled property to NO until I ended touch.

But the problem is that when I tap these several buttons at the same time, two or more touchesBegan methods work simultaneously, and message passing is messed up.

I tried to set multiTouchEnabled = NO and exclusiveTouch = YES, but it still didn't work.

How can I force to disable multitouch in my app?

Thank you.

Upvotes: 4

Views: 5950

Answers (1)

Justin Spahr-Summers
Justin Spahr-Summers

Reputation: 16973

You need to set exclusiveTouch to YES, not NO (which is the default anyways). The name of the property refers to the view being the exclusive recipient of any touch events for the duration.

Upvotes: 6

Related Questions