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
17
votes
2 answers

Prevent UIScrollView's UIPanGestureRecognizer from blocking UIScreenEdgePanGestureRecognizer

I have a UIScrollView that fills the screen on one page of my app, but I want to allow the user to pan from the edge of the screen to reveal a view behind it. The problem is that the UIScrollView steals the touches from my…
17
votes
2 answers

How to toggle a UILabel between editable and non-editable

How to make UILabel text editable on UILongPressGestureRecognizer. So that on long press it converts to editable and after removing focus from uilabel it become readonly.
KsK
  • 675
  • 1
  • 10
  • 22
17
votes
3 answers

Why is there a delay when moving object using UIPanGestureRecognizer?

I'm moving UIView object using UIPanGestureRecognizer — how much I drag my finger on screen, that much I move the view in the same direction (only in X - left or right, Y is not changing). It works fine, but with (very noticeable) delay. Here is the…
16
votes
3 answers

How to stop UIPanGestureRecognizer when object moved to certain frame

I have an object of image type which I am moving using UIPanGestureRecognizer, and I need to stop recognizing the UIPanGestureRecognizer when the object reaches a certain frame. UIPanGestureRecognizer *panRecognizer = [[UIPanGestureRecognizer…
16
votes
6 answers

Click events in UINavigationBar overridden by the gesture recognizer

The question in the first place was: When you have a tableView how to implement that the user can tap the NavigationBar to scroll all the way to the top. Solution: - (void)viewDidLoad { UITapGestureRecognizer* tapRecon =…
Octoshape
  • 1,131
  • 8
  • 26
16
votes
2 answers

bringSubviewToFront problem?

HI, I have Parentview-->Multiple childviews. when i use [self bringSubviewToFront:childview] in parentview, it works fine.but after adding grandchildview to childview,when i use [self bringSubviewToFront: grandchildview] in parentview, it did…
user141302
16
votes
5 answers

How to add a double tap Gesture Recognizer in Swift

I have already accomplished a single tap recognizer but can not figure out how to make that single tap recognizer a double tap instead. I could use some guidance. Code: import Foundation import UIKit class MainBoardController: UIViewController{ …
Hunter
  • 1,321
  • 4
  • 18
  • 34
16
votes
4 answers

Forward touches to a UIScrollView

I have two view controllers. View controller A has a UIScrollView and presents view controller B. The presentation is interactive and controlled by the scrollView.contentOffset. I want to integrate an interactive dismiss transition: When panning up,…
Ortwin Gentz
  • 52,648
  • 24
  • 135
  • 213
15
votes
4 answers

Get original touch location from UIPanGestureRecognizer

My view has a UIPanGestureRecognizer added to it. The problem is that by the time the touch is recognized as a pan gesture, it has to be moved a few points, and I can't extract the original touch location at the UIGestureRecognizerStateBegan…
antalkerekes
  • 2,128
  • 1
  • 20
  • 36
15
votes
4 answers

How to pass a 'tap' to UIButton that is underneath UIView with UISwipeGestureRecognizer?

I have a UIButton underneath a (transparent) UIView. The UIView above has a UISwipeGestureRecognizer added to it, and that is its only purpose - to detect certain swipe gestures. I want all other touches to be ignored by that UIView, and passed to…
danbretl
  • 644
  • 6
  • 14
15
votes
3 answers

UIButton not working when single tap gesture is added to superview

I have a UIButton set up and hooked up to an action in my view controller as usual. Just this by itself works fine. Now, I have added the following to my view controller to set up a single tap: - (void)viewDidLoad { [super…
Andrew
  • 567
  • 2
  • 5
  • 18
15
votes
2 answers

Detect any tap outside the current view

Is there a way to detect any tap outside the current view? I unsuccessfully tried to implement something with the hitTest method but I am not sure to understand it well.
user567
  • 3,712
  • 9
  • 47
  • 80
15
votes
2 answers

Detecting tap on a UITextView only detects cancellations

I have been struggling to detect a tap on a UITextView with Swift. My UITextViews are in a table, I must be able to detect links and press them, those links length are unknown. Also if I tap on the cell, that I don't tap on a link, I want push a…
Swift Rabbit
  • 1,370
  • 3
  • 14
  • 29
15
votes
6 answers

Disable gesture recognizer only for a particular view

On one view controller, I have one mainView. On that view I have another view, sidePanel, which has the frame 0,0,86,420. I have added a tap gesture recognizer. Now I want to just enable gesture recognition only for mainView and not for…
Ravindra Bagale
  • 17,226
  • 9
  • 43
  • 70
15
votes
1 answer

UIGestureRecognizers vs touchesBegan/touchesMoved/touchesEnded (accuracy)

I was printing the list of points I get using this two methods of touch tracking. The gesture recognisers are easier to use, but if you compare the points you get with the touchesBegan procedure, recognisers avoid some points, specifically at the…
Omer
  • 5,470
  • 8
  • 39
  • 64