Questions tagged [uigesturerecognizer]

UIGestureRecognizer is an abstract base class for concrete gesture-recognizer classes. A gesture-recognizer object (or, simply, a gesture recognizer) decouples the logic for recognizing a gesture and acting on that recognition. When one of these objects recognizes a common gesture or, in some cases, a change in the gesture, it sends an action message to each designated target object.

The UIGestureRecognizer class defines a set of common behaviors that can be configured for all concrete gesture recognizers. It can also communicate with its delegate (an object that adopts the UIGestureRecognizerDelegate protocol), thereby enabling finer-grained customization of some behaviors.

A gesture recognizer operates on touches hit-tested to a specific view and all of that view’s subviews. It thus must be associated with that view. To make that association you must call the UIView method addGestureRecognizer:. A gesture recognizer does not participate in the view’s responder chain.

A gesture recognizer has one or more target-action pairs associated with it. If there are multiple target-action pairs, they are discrete, and not cumulative. Recognition of a gesture results in the dispatch of an action message to a target for each of those pairs. The action methods invoked must conform to one of the following signatures:

 - (void)handleGesture;
 - (void)handleGesture:(UIGestureRecognizer *)gestureRecognizer;

Resources:

3632 questions
40
votes
15 answers

How can you add a UIGestureRecognizer to a UIBarButtonItem as in the common undo/redo UIPopoverController scheme on iPad apps?

Problem In my iPad app, I cannot attach a popover to a button bar item only after press-and-hold events. But this seems to be standard for undo/redo. How do other apps do this? Background I have an undo button (UIBarButtonSystemItemUndo) in the…
SG.
  • 401
  • 1
  • 5
  • 3
39
votes
2 answers

UIPanGestureRecognizer on MKMapView?

I would like to add some logic when user moves with map view i. e. he does a pan touch. But when I add the gesture recognizer and I want to log the touch, nothing happens. When I try it in another view controller and add the recognizer to…
JakubM
  • 2,685
  • 2
  • 23
  • 33
38
votes
1 answer

UIGestureRecognizer receive touch but forward it to UIControl as well

How would you allow a UIGestureRecognizer of a UIView to receive a touch event but also make sure that another, underlaying/overlaying UIView also receives that very same touch event? Lets say I have got the following view-hierachie: Views A (blue)…
Till
  • 27,559
  • 13
  • 88
  • 122
37
votes
6 answers

UISwipeGestureRecognizer Swipe length

Any idea if there is a way to get the length of a swipe gesture or the touches so that i can calculate the distance?
Tomo
  • 373
  • 1
  • 3
  • 4
36
votes
1 answer

Why am I getting this: [SystemGestureGate] <0x102210320> Gesture: System gesture gate timed out

My iOS Swift 5 (Xcode 14.1) app is humming along. After the last Xcode update, I noticed that when I push a particular view controller with a table view inside a stack, inside a navigation controller, I get the following…
flyer
  • 371
  • 1
  • 3
  • 6
36
votes
8 answers

Dismiss keyboard with swipe gesture (as in Message app)

When the keyboard is showing on the iPhone's Messages app, if the user begins a swipe down from the messages tableview and continues into the keyboard area, the keyboard will begin to dismiss. If they move their finger up and down during this…
Michael Stet
  • 361
  • 1
  • 3
  • 3
36
votes
1 answer

Swift UIGestureRecogniser follow finger

I'm making an iOS8 app using Swift. I'd like the user to be able to use gestures to reveal certain parts of the interface. So for example, the user slides their finger up and the view they slid their finger up moves out of the way, following their…
Francis
  • 919
  • 3
  • 14
  • 23
35
votes
6 answers

Gesture recognizer (swipe) on UIImageView

I am trying to NSLog when I swipe over an UIImageView with this code, but it does not work for some reason. Any idea ? @implementation ViewController - (void)viewDidLoad { [super viewDidLoad]; UIImage *image = [UIImage…
Sucrenoir
  • 2,994
  • 1
  • 27
  • 31
33
votes
3 answers

How to detect Swipe Gesture in iOS?

In my iPhone app, I require to recognize the swipe gesture made by the user on the view. I want the swipe gestures to be recognized and perform a function on swipe. I need that the view should horizontally slide and show another view as a user makes…
Parth Bhatt
  • 19,381
  • 28
  • 133
  • 216
33
votes
9 answers

Exclude subviews from UIGestureRecognizer

I have a UIView (the 'container view') which contains several 'sub views'. I want to add a UITapGestureRecognizer to the container view, such that it is activated when I touch the region inside the container view but outside the subviews. At the…
Awais Hussain
  • 1,501
  • 1
  • 14
  • 15
32
votes
5 answers

Detect horizontal panning in UITableView

I'm using a UIPanGestureRecognizer to recognize horizontal sliding in a UITableView (on a cell to be precise, though it is added to the table itself). However, this gesture recognizer obviously steals the touches from the table. I already got the…
Erik S
  • 1,939
  • 1
  • 18
  • 44
31
votes
2 answers

How do you stop UITapGestureRecognizer from catching EVERY tap?

Hello I have an opengl view and on that I have a tab bar. I'm using a tap recognizer to tap different 3d objects on screen. In the tab bar I have a button but it doesn't work because the tap recognizer catches these taps too. How do I stop this?…
gyozo kudor
  • 6,284
  • 10
  • 53
  • 80
29
votes
1 answer

iphone - single tap gesture conflicts with double one

I have a view. I wish to define to kinds of tap gestures for it. So if a user single tap on the view, view will do A; and if a user double tap on the view, it will do B without doing A. I added two UITapGestureRecognizer to the view. the single tap…
Jackson Tale
  • 25,428
  • 34
  • 149
  • 271
29
votes
3 answers

View controller lifecycle when swiping-to-pop from UINavigationController in iOS7

What is the impact of iOS 7's new swipe-to-pop gesture on the view controller lifecycle of UINavigationController?
28
votes
8 answers

Tap on UISlider to Set the Value

I created a Slider (operating as control of the video, like YouTube has at the bottom) and set the maximum (duration) and minimum values. And then used SeekToTime to change the currentTime. Now, the user can slide the thumb of the slider to change…
senty
  • 12,385
  • 28
  • 130
  • 260