Attaching gesture recognizers to UIKit controls
Learn how gesture recognizers interact with UIKit controls such as buttons, switches, and sliders.
Overview
Gesture recognizers attached to your views don’t impact the ability of UIKit controls to handle events. Events occurring within the bounds of a control are handled by the control first, giving the control a chance to call its action method. Specifically, UIKit controls call their action method in the following situations:
A single finger single tap occurs on a UIButton, UISwitch, UIStepper, UISegmentedControl, or UIPageControl object.
A single finger swipe occurs on the knob of a UISlider object, in a direction parallel to the slider.
A single finger pan occurs on the knob of a UISwitch object, in a direction parallel to the switch.
To handle any of the preceding gestures before the control calls its action method, install your gesture recognizer on the control itself. Gesture recognizers handle touch events before the views to which they’re attached. As a result, installing a gesture recognizer directly on a control prevents that control from calling its action method.