Instance Method

touchesBegan:withEvent:

Sent to the gesture recognizer when one or more fingers touch down in the associated view.

Declaration

- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event;

Parameters

touches

A set of UITouch instances in the event represented by event that represent the touches in the UITouchPhaseBegan phase.

event

A UIEvent object representing the event to which the touches belong.

Discussion

This method has the same exact signature as the corresponding one declared by UIResponder. Through this method a gesture recognizer receives touch objects (in their UITouchPhaseBegan phase) before the view attached to the gesture recognizer receives them. UIGestureRecognizer objects are not in the responder chain, yet observe touches hit-tested to their view and their view's subviews. After observation, the delivery of touch objects to the attached view, or their disposition otherwise, is affected by the cancelsTouchesInView, delaysTouchesBegan, and delaysTouchesEnded properties.

If the gesture recognizer is interpreting a continuous gesture, it should set its state to UIGestureRecognizerStateBegan upon receiving this message. If at any point in its handling of the touch objects the gesture recognizer determines that the multi-touch event sequence is not its gesture, it should set it state to UIGestureRecognizerStateCancelled.

Multiple touches are disabled by default. In order to receive multiple touch events you must set the a multipleTouchEnabled property of the attached view instance to YES.

See Also

Methods for Subclasses

- touchesMoved:withEvent:

Sent to the gesture recognizer when one or more fingers move in the associated view.

- touchesEnded:withEvent:

Sent to the gesture recognizer when one or more fingers lift from the associated view.

- touchesCancelled:withEvent:

Sent to the gesture recognizer when a system event (such as an incoming phone call) cancels a touch event.

- touchesEstimatedPropertiesUpdated:

Sent to the gesture recognizer when the estimated properties for a touch have changed so that they are no longer estimated, or an update is no longer expected.

- reset

Overridden to reset internal state when a gesture recognition attempt completes.

- ignoreTouch:forEvent:

Tells the gesture recognizer to ignore a specific touch of the given event.

- canBePreventedByGestureRecognizer:

Overridden to indicate that the specified gesture recognizer can prevent the receiver from recognizing a gesture.

- canPreventGestureRecognizer:

Overridden to indicate that the receiver can prevent the specified gesture recognizer from recognizing its gesture.

- shouldRequireFailureOfGestureRecognizer:

Overridden to indicate that the receiver requires the specified gesture recognizer to fail.

- shouldBeRequiredToFailByGestureRecognizer:

Overridden to indicate that the receiver should be required to fail by the specified gesture recognizer.

- ignorePress:forEvent:

Tells the gesture recognizer to ignore a specific press of the given event.

- pressesBegan:withEvent:

Sent to the receiver when a physical button is pressed in the associated view.

- pressesChanged:withEvent:

Sent to the receiver when the force of the press has changed in the associated view.

- pressesEnded:withEvent:

Sent to the receiver when a button is released from the associated view.

- pressesCancelled:withEvent:

Sent to the receiver when a system event (such as a low-memory warning) cancels a press event.