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
62
votes
5 answers

Detecting Pan Gesture End

I've got a view and I applied a UIPanGestureRecogniser to this view: UIPanGestureRecognizer *panGesture = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panAnim:)]; [sliderView addGestureRecognizer:panGesture]; [panGesture…
Dan Hanly
  • 7,829
  • 13
  • 73
  • 134
61
votes
15 answers

GestureRecognizer not responding to tap

After initialisation of by subclass of UIImageView I have the following line of code: self.userInteractionEnabled = true self.addGestureRecognizer(UITapGestureRecognizer(target: self, action: "handleTap:")) I created the necessary associated…
Didia
  • 1,396
  • 1
  • 12
  • 18
59
votes
12 answers

tap gesture recognizer - which object was tapped?

I'm new to gesture recognizers so maybe this question sounds silly: I'm assigning tap gesture recognizers to a bunch of UIViews. In the method is it possible to find out which of them was tapped somehow or do I need to find it out using the point…
suMi
  • 1,536
  • 1
  • 17
  • 30
58
votes
5 answers

Forwarding UIGesture to views behind

I am working on an iphone (iOS 4.0 or later) app and having some troubles with touch handling between multiple views. I am having a view structure like this ---> A superView | ---> SubView - A | ---> SubView - B (exactly on top…
Krishnabhadra
  • 34,169
  • 30
  • 118
  • 167
57
votes
4 answers

How to get UITouch location from UIGestureRecognizer

I want to get the UITouch location of my tap from UIGestureRecognizer, but I can not figure out how to from looking at both the documentation and other SO questions. Can one of you guide me? - (void)handleTap:(UITapGestureRecognizer…
Oscar Apeland
  • 6,422
  • 7
  • 44
  • 92
56
votes
15 answers

UIPageViewController Gesture recognizers

I have a UIPageViewController load with my Viewcontroller. The view controllers have buttons which are overridden by the PageViewControllers gesture recognizers. For example I have a button on the right side of the viewcontroller and when you press…
Rich86man
  • 6,507
  • 2
  • 26
  • 27
52
votes
3 answers

Swift3 iOS - How to make UITapGestureRecognizer trigger function

I am trying to add a UITapGesture to a UIButton so it will trigger a function when tapped. I am using Swift 3 and is getting some error: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SwiftRunner.ViewController…
iSebbeYT
  • 1,441
  • 2
  • 18
  • 29
49
votes
5 answers

How do I implement the UITapGestureRecognizer into my application

I am quite new to programming and Objective C. I was wondering how to make an app which has a blank screen and a timer that goes for one minute. You are meant to tap as fast as you can and as long as you can for. I was wondering how to implement the…
45
votes
4 answers

Intercepting pan gestures over a UIScrollView breaks scrolling

I have a vertically-scrolling UIScrollView. I want to also handle horizontal pans on it, while allowing the default vertical scroll behavior. I've put a transparent UIView over the scroll view, and added a pan gesture recognizer to it. This way I…
44
votes
4 answers

UIGestureRecognizer and UITableViewCell issue

I am attaching a UISwipeGestureRecognizer to a UITableViewCell in the cellForRowAtIndexPath: method like so: - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString…
mootymoots
  • 4,545
  • 9
  • 46
  • 74
44
votes
1 answer

Add UIGestureRecognizer to swipe left to right right to left my views

I have a UIStoryboard with different UIViewControllers, I would like to add another UIViewController (like a dashboard) that when the user swipe the ipad from left the dashboard will appear then when he swipe back the current view will be…
43
votes
5 answers

Combine longpress gesture and drag gesture together

I'm moving my views by UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(moveRight:)]; [panRecognizer setMinimumNumberOfTouches:1]; [panRecognizer…
PJR
  • 13,052
  • 13
  • 64
  • 104
43
votes
3 answers

UIView animation based on UIPanGestureRecognizer velocity

I would like to be able to move a subview on and off the screen much like you browse between images in the iPhone's build in Photos app, so if the subview is more than 1/2 off screen when I let go with my finger it must animate off screen, but it…
42
votes
3 answers

Disable gesture recognizer

I have two types of recognizer, one for tap and one for swipe UIGestureRecognizer *recognizer; //TAP recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(numTap1:)]; [(UITapGestureRecognizer *)recognizer…
Vins
  • 1,814
  • 4
  • 24
  • 40
41
votes
7 answers

Does UIGestureRecognizer work on a UIWebView?

I am attempting to get a UIGestureRecognizer working with a UIWebview which is a subview of a UIScrollView. This sounds odd but when I have the numberOfTouchesRequired set to 2 the selector fires, but when numberOfTouchesRequired is set to one the…
rscott
  • 616
  • 1
  • 6
  • 9