My app has several buttons which trigger different events. The user should NOT be able to hold down several buttons. Anyhow, holding down several buttons crashes the app.
And so, I'm trying to disable multi-touch in my app.
I've unchecked 'Multiple Touch' in all the xib files, and as far as I can work out, the properties 'multipleTouchEnabled' and 'exclusiveTouch' control whether the view uses multitouch. So in my applicationDidFinishLaunching I've put this:
self.mainViewController.view.multipleTouchEnabled=NO;
self.mainViewController.view.exclusiveTouch =YES;
And in each of my view controllers I've put this in the viewDidLoad
self.view.multipleTouchEnabled=NO;
self.view.exclusiveTouch=YES;
However, it still accepts multiple touches. I could do something like disable other buttons after getting a touch down event, but this would be an ugly hack. Surely there is a way to properly disable multi-touch?
I created UIView Class Extension and added this two functions. and when i want to disable view touch i just call [view makeExclusiveTouch];
For disabling global multitouch in Xamarin.iOS
Copy&Paste the code below:
And set it on AppDelegate:
I've just had exactly this problem.
The solution we came up with was simply to inherit a new class from UIButton that overrides the initWithCoder method, and use that where we needed one button push at a time (ie. everywhere):
Note that this only works with buttons loaded from nib files.
If you want to disable multi touch throughout the application and don't want to write code for each button then you can simply use
Appearance
of button. Write below line indidFinishLaunchingWithOptions
.Thats great!! UIAppearance
You can even use it for any of
UIView
class so if you want to disable multi touch for few buttons. Make a CustomClass of button and thenThere is one more advantage which can help you. In case you want to disable multi touch of buttons in a particular
ViewController
If you want to disable multitouch programmatically, or if you are using cocos2d (no multipleTouchEnabled option), you can use the following code on your ccTouches delegate: