UILongPressGestureRecognizer Class Reference

Inherits from
Conforms to
Framework
/System/Library/Frameworks/UIKit.framework
Availability
Available in iOS 3.2 and later.
Companion guide
Declared in
UILongPressGestureRecognizer.h
Related sample code

Overview

UILongPressGestureRecognizer is a concrete subclass of UIGestureRecognizer that looks for long-press gestures. The user must press one or more fingers on a view for at least a specified period for the action message to be sent. In addition, the fingers may move only a specified distance for the gesture to be recognized; if they move beyond this limit the gesture fails.

Long-press gestures are continuous. The gesture begins (UIGestureRecognizerStateBegan) when the number of allowable fingers (numberOfTouchesRequired) have been pressed for the specified period (minimumPressDuration) and the touches do not move beyond the allowable range of movement (allowableMovement). The gesture recognizer transitions to the Change state whenever a finger moves, and it ends (UIGestureRecognizerStateEnded) when any of the fingers are lifted.

Tasks

Configuring the Gesture Recognizer

Properties

allowableMovement

The maximum movement of the fingers on the view before the gesture fails.

@property(nonatomic) CGFloat allowableMovement
Discussion

The allowable distance is in pixels. The default distance is 10 pixels.

Availability
  • Available in iOS 3.2 and later.
Declared In
UILongPressGestureRecognizer.h

minimumPressDuration

The minimum period fingers must press on the view for the gesture to be recognized.

@property(nonatomic) CFTimeInterval minimumPressDuration
Discussion

The time interval is in seconds. The default duration is is 0.5 seconds.

Availability
  • Available in iOS 3.2 and later.
Related Sample Code
Declared In
UILongPressGestureRecognizer.h

numberOfTapsRequired

The number of taps on the view required for the gesture to be recognized.

@property (nonatomic) NSUInteger numberOfTapsRequired
Discussion

The default number of taps is 0.

Availability
  • Available in iOS 3.2 and later.
Declared In
UILongPressGestureRecognizer.h

numberOfTouchesRequired

The number of fingers that must be pressed on the view for the gesture to be recognized.

@property(nonatomic) NSInteger numberOfTouchesRequired
Discussion

The default number of fingers is 1.

Availability
  • Available in iOS 3.2 and later.
Declared In
UILongPressGestureRecognizer.h

Did this document help you? Yes It's good, but... Not helpful...