Posted By

tenveer on 10/05/10


Tagged

single double tap touchesbegain


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

bobbym245


getting a single a double tap touch event


 / Published in: Objective C
 

execute different functions on single or double tap

  1. - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
  2. {
  3.  
  4. UITouch *touch = touches.anyObject;
  5. _dragStartPos = [touch locationInView:self];
  6.  
  7. /////////Logic To Handle Single and Double Tap
  8.  
  9. //the the first tap delegate message if its a double tap and so on
  10. [NSObject cancelPreviousPerformRequestsWithTarget:self
  11. selector:@selector(singleTap)
  12. object:nil];
  13.  
  14. [NSObject cancelPreviousPerformRequestsWithTarget:self
  15. selector:@selector(doubleTap)
  16. object:nil];
  17.  
  18. //logic to get the tap count
  19. if(touches.count == 1)
  20. {
  21. if([[touches anyObject] tapCount] == 2)
  22. {
  23. [self performSelector:@selector(doubleTap)
  24. withObject:nil
  25. afterDelay:0.35];
  26. }
  27. else if([[touches anyObject] tapCount] == 3)
  28. {
  29. [self trippleTap];
  30. }
  31. else
  32. {
  33. [self performSelector:@selector(singleTap)
  34. withObject:nil
  35. afterDelay:0.35];
  36. }
  37. }
  38.  
  39.  
  40. }

Report this snippet  

You need to login to post a comment.