TouchUpInside on UIView with children

You can change the UIView's class in the Identity Inspector ... make it UIControl and then you can add an event for UITouchUpInside for your view - to catch the taps on it.

Good luck!

EDIT: here's a step-by-step with screenshots:

The view... Original view - of type UIView

... of course, no events. UIView has no events you can use

Go back and change UIView with UIControl and... Change UIView to UIControl

Ta-daa! Events! UIControl allows you to use events

Hook a method to the UITouchUpInside event Add event for UITouchUpInside

This is how it should look like in the interface file The interface of the method

This is how it should look like in the implementation file (you can, of course, replace the logging with anything you want) The implementation of the method


This works for me

Swift 3

 let gesture = UITapGestureRecognizer(target: self, action: selector(self.customViewClick))
withSender: self)
 customView.addGestureRecognizer(gesture)


 func customViewClick()  {
     print("custom view clicked!")
    }

You can feign this behaviour by having a gesture recogniser for your parent view and ensuring that your children do not have their own gesture recognisers. To do this add a gesture recogniser to your parent UIView that listens for taps. Where parentView is the containing view for your child views (UILabels/UIImageView) and handleTap is a method implemented by parentView, do something like:

UIGestureRecognizer *tapParent = [[UITapGestureRecognizer alloc]initWithTarget:parentView action:@selector(handleTap)];
[parentView addGestureRecognizer:tapParent];
[tapParent release];

As your child views do not have their own gesture recognisers they will not 'eat' the gesture and so the parent view will respond so long as you tap within its bounds.