getting a single a double tap touch event


/ Published in: Objective C
Save to your folder(s)

execute different functions on single or double tap


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.