Creating the Return Gesture Recognizer
Before you create the gesture recognizer, you need to choose a gesture and determine how to detect it. Since it returns the iPad app to a known state, you can use a small letter r. The first challenge is determining how to recognize the character.
The easiest way to recognize a stroke is by breaking it down into components separated by transitions in x
and/or y
movement. As part of the events, you get both the current and previous touch points, allowing detection of changes in movement. The x
value increases from left to right of the screen, and y
increases from top to bottom. You can use comparisons between previous and current positions to determine changes in direction. If you needed other information ...
Get Learning iOS Development: A Hands-on Guide to the Fundamentals of iOS Programming now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.