Tap is a gesture in which you quickly touch and remove the finger from the screen. There is a separate gesture recognizer for this as well.
Similarly to the swipe gesture recognizer, we just have to assign a function that will get called once the gesture is recognized. Add the following code to the class:
UITapGestureRecognizer* tapGestureRecognizer = [[UITapGestureRecognizeralloc] initWithTarget:self action:@selector(handleTap:)]; [[UIApplicationsharedApplication].delegate.windowaddGestureRecognizer:tapGestureRecognizer];
Here, we will create a variable of the UITapGestureRecognizer
type, allocate and initialize it with a function, and set the delegate as self
.
Next, add the following function that will get called once the tap is complete:
- (void)handleTap:(UIGestureRecognizer*)recognizer { NSLog(@"TAP"); }
Now, your class can recognize the taps.
3.14.145.82