0

Possible Duplicate:
ios sdk stop multitouch functionality

I have a bunch of buttons all of them call the same function. The function includes an animation of the button itself. Suppose the user click any of the buttons and get what is supposed to show. However, it's possible that user use two fingers and touched two buttons at the same time (or nearly same time). In such case I see two buttons begin to animate. How can I limit only one button to call the function at a time.

Community
  • 1
  • 1
Tony Xu
  • 3,031
  • 4
  • 32
  • 43

2 Answers2

14
You can set exclusive touch to all buttons-
[button setExclusiveTouch:YES];

Take a look at iOS: setting Exclusive Touch to all buttons in a view

Community
  • 1
  • 1
Rahul Wakade
  • 4,765
  • 2
  • 23
  • 25
  • This works! Thanks a lot. accept your answer. others' suggestion didn't work, as I had tested before I post here. – Tony Xu Nov 21 '12 at 06:30
1

Set a BOOL value to YES. When you press the first button. And set it to NO in the animation completed block. And check the BOOL for calling the animation method, if the BOOL is YES then don't call the second button's animation or remove first button's animation and call second method's animation.

@interface yourClass
{
   BOOL animationStarted;
}
@end

-(IBAction)click:(id)sender
{
   if(!animationStarted)
   {
      animationStarted = YES;
      //call the animation
   }
   else
   {
      //you can do two things here
      //1.Skip the second button click
      //2.Remove first button animation and start second button animation
   }
}

In the animation completion block: set animationStarted = NO;

Midhun MP
  • 103,496
  • 31
  • 153
  • 200