Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

prevent buttons from being pressed simultaneously

Tags:

ios

uibutton

This is a simple problem, but tricky to solve.

I have two buttons that perform the same function.

I've set different touch events for the buttons. Although this helps, it's still possible to press them simultaneously. On a slow connection, it will be even easier.

[vote1Btn addTarget:self action:@selector(voteUp:) forControlEvents:UIControlEventTouchUpInside];
[vote2Btn addTarget:self action:@selector(voteUp:) forControlEvents:UIControlEventTouchDown];
like image 930
mikeholp Avatar asked Apr 14 '13 03:04

mikeholp


1 Answers

Set the exclusiveTouch property of both buttons to YES.

If that isn't enough, have each button call the shared application object's beginIgnoringInteractionEvents when its operation starts and call endIgnoringInteractionEvents when its operation ends.

like image 78
matt Avatar answered Nov 09 '22 11:11

matt