Drag Gesture Recognizer

Dragging a view is a continuous recognizer. The action method is called repeatedly as long as the finger is down and the recognizer is in an appropriate state. As explained earlier in this chapter, in the section “Custom Recognizers,” continuous recognizers have more states. Create your own continuous recognizer for dragging a view by following these steps:

1. Select the Other group in the Navigator and add the new class DragViewGesture, based on UIGestureRecognizer.

2. Import the gesture recognizer subclass:

#import <UIKit/UIGestureRecognizerSubclass.h>

3. Add the methods shown here:

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {     [super ...

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.