ios gesture recognizers
play

iOS Gesture Recognizers CocoaConf Boston October 2013 Jonathan - PowerPoint PPT Presentation

iOS Gesture Recognizers CocoaConf Boston October 2013 Jonathan Penn @jonathanpenn Slides n Sample Code rubbercitywizards.com/stu ff Ti e problem... - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event -


  1. iOS Gesture Recognizers CocoaConf Boston • October 2013 Jonathan Penn

  2. @jonathanpenn

  3. Slides n’ Sample Code rubbercitywizards.com/stu ff

  4. Ti e problem...

  5. - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event

  6. - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { remember when, where for the touches }

  7. - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { if one finger: is user panning? adjust offset if two fingers: am I rotating? what angle? am I pinching? what scale? }

  8. - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { if one finger: is user panning? adjust offset if two fingers: am I rotating? what angle? am I pinching? what scale? }

  9. - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { if one finger: is user panning? adjust offset if two fingers: am I rotating? what angle? am I pinching? what scale? }

  10. - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { if one finger: is user panning? adjust offset if two fingers: am I rotating? what angle? am I pinching? what scale? }

  11. - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { if one finger: is user panning? adjust offset if two fingers: am I rotating? what angle? am I pinching? what scale? }

  12. - (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { if one finger: is user panning? adjust offset if two fingers: am I rotating? what angle? am I pinching? what scale? }

  13. - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { did we already pan? did we already rotate? did we already pinch? did we move to far for a tap? did we wait to long for a tap? if not: then TAP! }

  14. - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { did we already pan? did we already rotate? did we already pinch? did we move to far for a tap? did we wait to long for a tap? if not: then TAP! }

  15. - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { did we already pan? did we already rotate? did we already pinch? did we move to far for a tap? did we wait to long for a tap? if not: then TAP! }

  16. - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { did we already pan? did we already rotate? did we already pinch? did we move to far for a tap? did we wait to long for a tap? if not: then TAP! }

  17. - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { did we already pan? did we already rotate? did we already pinch? did we move to far for a tap? did we wait to long for a tap? if not: then TAP! }

  18. - (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event { did we already pan? did we already rotate? did we already pinch? did we move to far for a tap? did we wait to long for a tap? if not: then TAP! }

  19. Phew!

  20. But wait, there’s more...

  21. What we want...

  22. - (void)panned:(id)coordinates { // ... } - (void)tapped:(id)coordinates { // ... } - (void)doubleTapped:(id)coordinates { // ... }

  23. UIView target/action - (void)tapped:

  24. How do they work?

  25. possible recognized failed

  26. possible recognized failed

  27. possible ended cancelled began changed

  28. - (void)panned:(id)recognizer { // ... } - (void)tapped:(id)recognizer { // ... } - (void)doubleTapped:(id)recognizer { // ... }

  29. A long press by any other name takes just as long.

  30. By our powers combined....

  31. delegate target/action target/action UIViewController <UIGestureRecognizerDelegate> � - (BOOL)gestureRecognizer:... shouldRecognizeSimultaneouslyWithGestureRecognizer:...

  32. - (void)pinched:(id)recognizer { // ... } - (void)rotated:(id)recognizer { // ... }

  33. Reduce. Reuse. Recognize.

  34. To the Demo!

  35. Walkthrough Example github.com/jonathanpenn/GestureExample Mark’s Gesture Lab github.com/markd2/GestureLab

  36. @jonathanpenn jonathan@rubbercitywizards.com for more info… rubbercitywizards.com/stu ff

Recommend


More recommend