Swift : Button click stops tapGestureDidRecognize on the parent View

910 views Asked by At

Is it possible to be able to click a button and let the tap trickle down to the parent View of a button? I have tried disabling the button and the tap gets detected, but is it possible to click on the button, do something and then let the tap event trickle down?

UIViewControllerWrapperView contains UIView contains UIView contains UIButton

When I click/press the button should go like so,

Click button > UIView tapped > UIView tapped > UIViewControllerWrapperView detect tap

Edit: I can detect Taps on UIViewControllerWrapperView, however, if I click on the button, the Taps are not detected because I'm assuming the click event gets handled by the button which in turn blocks the tap from being detected by the views underneath.

1

There are 1 answers

3
Mobile Dan On BEST ANSWER

isUserInteractionEnabled property

Try setting the UIButton's isUserInteractionEnabled property to false. The default is true for a UIButton.

Note that isUserInteractionEnabled is declared on the UIView class which UIButton inherits from.

 

Set isUserInteractionEnabled in Code

button.isUserInteractionEnabled = false

 

Set isUserInteractionEnabled in Interface Builder

In attributes inspector for the UIButton:

enter image description here