Creating a Tap Gesture

Hi, here is a basic example of creating and applying a tap gesture.
This is one of the simpler gestures and it’s fairly easy to use.

First we are going to create the Gesture Recognizer, using the built in UITapGestureRecognizer function provided by Apple.

Please make sure the

matches the function name below.

Now for the function – we are just going to put anything you want
happening when your object is being tapped.
Let’s say we are just going to print a console message “tap tap tap”:

Then we are just going to apply our new gesture to any item we want.
Lets say we have an image, within an UIImageView and we want to be
able to tap that:

Further you could add an action for image pick within the TapGesture function.
This is used to load an image after a tap has been detected.

Please refer to the image picker function here: Image Picker

Tagged with 

Leave a Reply

Your email address will not be published. Required fields are marked *