Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITapGestureRecognizer with target - Swift

Tags:

I tried to make a simple tap gesture and I can't figure it out. I want to add a target, simple selector to the gesture.

Here is my code :

var panGesture : UIGestureRecognizer = UITapGestureRecognizer.addTarget(<#UIGestureRecognizer#>) 

How can I set selector?

like image 496
Ron Avatar asked Jun 06 '14 15:06

Ron


People also ask

What is UITapGestureRecognizer Swift?

UITapGestureRecognizer is a concrete subclass of UIGestureRecognizer . For gesture recognition, the specified number of fingers must tap the view a specified number of times. Although taps are discrete gestures, they're discrete for each state of the gesture recognizer.

How to set tap gesture in ios?

Adding a Tap Gesture Recognizer in Interface Builder You don't need to switch between the code editor and Interface Builder. Open Main. storyboard and drag a tap gesture recognizer from the Object Library and drop it onto the view we added earlier. The tap gesture recognizer appears in the Document Outline on the left.

What is Pan gesture in Swift?

A pan gesture occurs any time a person moves one or more fingers around the screen. A screen-edge pan gesture is a specialized pan gesture that originates from the edge of the screen. Use the UIPanGestureRecognizer class for pan gestures and the UIScreenEdgePanGestureRecognizer class for screen-edge pan gestures.


1 Answers

Should look something like this:

var tapGesture = UITapGestureRecognizer(target: self, action: "SomeMethod") self.view.addGestureRecognizer(tapGesture) 
like image 158
Kris Gellci Avatar answered Sep 22 '22 15:09

Kris Gellci