Specializing Recognizer Messages

You can create a custom recognizer by subclassing UIGestureRecognizer and implementing one or more of the touch event handlers. You are also likely to implement other methods from the superclass, as well as your own logic and state variables.

The recognizer has two main jobs: Keep the gestures state up to date and recognize your custom stroke and/or perform your custom behavior. The main event handler methods follow the sequence of a stroke:

Image touchesBegan:withEvent: is sent when the touches first occur—that is, when the user touches the screen.

touchesMoved:withEvent: is sent each time the user moves one or more ...

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.