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
20
votes
14 answers

How to enable "tap and slide" in a UISlider?

What I want to get is a UISlider which lets the user not only slide when he starts on its thumbRect, but also when he taps elsewhere. When the user taps on the slider but outside of the thumbRect, the slider should jump to that value and then still…
Norbert
  • 4,239
  • 7
  • 37
  • 59
20
votes
5 answers

Navigation pop view when swipe right like Instagram iPhone app.How i achieve this?

I want to pop a view when swipe right on screen or it's work like back button of navigation bar. I am using: self.navigationController.interactivePopGestureRecognizer.delegate = (id)self; This single line of code for…
Chetu
  • 428
  • 1
  • 7
  • 19
20
votes
3 answers

UISystemGateGestureRecognizer and delayed taps near bottom of screen

What are the standard UISystemGestureGateGestureRecognizers installed on the top level UIView of an iOS app for? My app consists of two views - one fills the top half of the screen, the other is a custom keyboard and fills the bottom half. I found…
Brad Robinson
  • 44,114
  • 19
  • 59
  • 88
20
votes
7 answers

UIPanGestureRecognizer do something immediately when touched

I am new to ios, so I apologize in advance if I am missing something obvious. I am creating a puzzle where I would like the individual puzzle pieces to increase in size on touch and decrease on letting go. Currently I…
buczek
  • 2,011
  • 7
  • 29
  • 40
20
votes
4 answers

UIPanGestureRecognizer on UITableViewCell overrides UITableView's scroll view gesture recognizer

I've subclassed UITableViewCell and in that class I apply a Pan gesture recogniser: UIPanGestureRecognizer *panning = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(handlePanning:)]; panning.minimumNumberOfTouches =…
sooper
  • 5,991
  • 6
  • 40
  • 65
19
votes
3 answers

How to cancel/reset an UIGestureRecognizer

how can I cancel or reset an UIGestureRecognizer? The problem is, that if I set waitForSomething to NO during a gesture, the next event is UIGestureRecognizerStateChanged. But the first event should be UIGestureRecognizerStateBegan. My Code: -…
Manni
  • 11,108
  • 15
  • 49
  • 67
19
votes
4 answers

How to cancel UIGestureRecognizer if subview's button pressed

I am struggling to get the behaviour I would like from the gesture recognisers, specifically cancelling certain gestures if others have fired. I have a scrollView set to paging and multiple subviews in each page. I have added a touch gesture…
Magic Bullet Dave
  • 9,006
  • 10
  • 51
  • 81
19
votes
6 answers

Getting the UITouch objects for a UIGestureRecognizer

Is there a way to get the UITouch objects associated with a gesture? UIGestureRecognizer doesn't seem to have any methods for this.
Morrowless
  • 6,856
  • 11
  • 51
  • 81
18
votes
7 answers

iOS: How to get duration of long press gesture?

I'm working on a game in which an attribute of a game object is set by long pressing on the object itself. The value of the attribute is determined by the duration of the long press gesture. I'm using UILongPressGestureRecognizer for this purpose,…
Ryan Dao
  • 321
  • 1
  • 4
  • 13
18
votes
5 answers

Using parameters in action of UITapGestureRecognizer in Swift

I am trying to call a function with parameters using the action of UITapGestureRecognizer and I can't figure out any alternative. This here is the gesture that is suppose to call the doubleTap function with the indexPath parameter. var…
Cherryholme
  • 254
  • 2
  • 4
  • 11
18
votes
5 answers

UINavigationContoller interactivePopGestureRecognizer inactive when navigation bar is hidden

I have a view controller which is nested within a UINavigationController. I have implemented the iOS 7 interactivePopGestureRecognizer to enable the user to gesture to pop a VC off the stack. Within the VC i have a scrollview and whilst the user is…
Dan
  • 1,447
  • 2
  • 14
  • 30
18
votes
2 answers

UIGestureRecognizer causes circular retain?

I was thinking, if you assign the target as self in the gesture recogniser's initWithTarget:action: method, will you cause a circular retain? Since self will retain the recogniser in self.gestureRecognizers and it's possible the gesture recogniser…
Meda
  • 2,776
  • 4
  • 20
  • 31
17
votes
3 answers

How to reliably find correct view for UIGestureRecognizer?

I have a bunch of UIViews like in the image below. The red/pink (semi-transparent) view is on top of the others. Red has a UISwipeGestureRecognizer. Green has as a UITapGestureRecognizer. Blue has no recognizer. A tap on the visible…
Martin Wickman
  • 19,662
  • 12
  • 82
  • 106
17
votes
3 answers

How to make tableViewCell handle both tap and longPress?

I put this in cellForRowAtIndexPath let longPress = UILongPressGestureRecognizer(target: self, action: #selector(CalorieCountViewController.handleLongPress)) cell.addGestureRecognizer(longPress) longPress.cancelsTouchesInView = true let tapPress =…
den330
  • 387
  • 1
  • 3
  • 15
17
votes
4 answers

How can I detect the scroll direction from the UICollectionView?

I have a UICollectionView. I want to detect scroll direction. I have a two different animation style for scroll down and scroll up. So I must learn scroll direction. CGPoint scrollVelocity =…