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.
uigesturerecognizer
3,637
questions
388
votes
7
answers
97k
views
UILongPressGestureRecognizer gets called twice when pressing down
I am detecting if the user has pressed down for 2 seconds:
UILongPressGestureRecognizer *longPress = [[UILongPressGestureRecognizer alloc]
initWithTarget:...
349
votes
18
answers
171k
views
How to disable back swipe gesture in UINavigationController on iOS 7
In iOS 7 Apple added a new default navigation behavior. You can swipe from the left edge of the screen to go back on the navigation stack. But in my app, this behavior conflicts with my custom left ...
257
votes
13
answers
90k
views
Can you attach a UIGestureRecognizer to multiple views?
UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapTapTap:)];
[self.view1 addGestureRecognizer:tapGesture];
[self.view2 addGestureRecognizer:...
231
votes
24
answers
412k
views
How to call gesture tap on UIView programmatically in swift
I have a UIView and and I have added tap gesture to it:
let tap = UITapGestureRecognizer(target: self, action: Selector("handleTap:"))
tap.delegate = self
myView.addGesture(tap)
I am trying to call ...
186
votes
8
answers
110k
views
UIGestureRecognizer on UIImageView
I have a UIImageView, which I want to be able to resize and rotate etc.
Can a UIGestureRecognizer be added to the UIImageView?
I would want to add a rotate and pinch recognizer to a UIImageView ...
171
votes
9
answers
110k
views
UITapGestureRecognizer - single tap and double tap
I am trying to add 2 UITapGestureRecognizers to a view, one for single tap and one for double tap events. The single tap recognizer is working as expected (on its own). But I don't seem to be able ...
158
votes
22
answers
77k
views
UIPanGestureRecognizer - Only vertical or horizontal
I have a view that has a UIPanGestureRecognizer to drag the view vertically. So in the recognizer callback, I only update the y-coordinate to move it. The superview of this view, has a ...
151
votes
25
answers
109k
views
How do I Disable the swipe gesture of UIPageViewController?
In my case parent UIViewController contains UIPageViewController which contains UINavigationController which contains UIViewController. I need to add a swipe gesture to the last view controller, but ...
125
votes
17
answers
64k
views
Disable gesture to pull down form/page sheet modal presentation
In iOS 13 modal presentations using the form and page sheet style can be dismissed with a pan down gesture. This is problematic in one of my form sheets because the user draws into this box which ...
102
votes
9
answers
87k
views
Gesture recognizer and button actions
I have a view hierarchy that looks something like this:
UIView (A)
UIView > UIImageView
UIView > UIView (B)
UIView > UIView (B) > Rounded Rect Button
UIView > UIView (B) > ...
99
votes
19
answers
51k
views
No Swipe Back when hiding Navigation Bar in UINavigationController
I love the swipe pack thats inherited from embedding your views in a UINavigationController. Unfortunately i cannot seem to find a way to hide the NavigationBar but still have the touch pan swipe ...
85
votes
10
answers
68k
views
UIGestureRecognizer blocks subview for handling touch events
I'm trying to figure out how this is done the right way. I've tried to depict the situation:
I'm adding a UITableView as a subview of a UIView. The UIView responds to a tap- and ...
74
votes
7
answers
41k
views
How can I tell a UIGestureRecognizer to cancel an existing touch?
I have a UIPanGestureRecognizer I am using to track an object (UIImageView) below a user's finger. I only care about motion on the X axis, and if the touch strays above or below the object's frame on ...
68
votes
3
answers
59k
views
How to remove all gesture recognizers from a UIView in Swift
I have written Swift code that attempts to remove all gesture recognizers from all subviews of a given custom UIView type.
let mySubviews = self.subviews.filter() {
$0.isKindOfClass(CustomSubview)
...
63
votes
3
answers
40k
views
How can I capture which direction is being panned using UIPanGestureRecognizer?
Ok so I have been looking around at just about every option under the sun for capturing multi-touch gestures, and I have finally come full circle and am back at the UIPanGestureRecognizer.
The ...
62
votes
15
answers
86k
views
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: "...
62
votes
5
answers
45k
views
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 ...
59
votes
12
answers
120k
views
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 ...
58
votes
5
answers
47k
views
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
|
---> ...
57
votes
4
answers
67k
views
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)...
56
votes
15
answers
54k
views
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 ...
52
votes
3
answers
79k
views
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 '...
49
votes
5
answers
89k
views
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 ...
46
votes
4
answers
45k
views
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 ...
46
votes
1
answer
20k
views
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, ...
44
votes
1
answer
55k
views
Add UIGestureRecognizer to swipe left to right right to left my views [duplicate]
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 ...
44
votes
4
answers
35k
views
UIGestureRecognizer and UITableViewCell issue
I am attaching a UISwipeGestureRecognizer to a UITableViewCell in the cellForRowAtIndexPath: method like so:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath ...
43
votes
5
answers
30k
views
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];
[...
43
votes
3
answers
38k
views
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 ...
42
votes
3
answers
52k
views
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:)];
[(...
41
votes
7
answers
38k
views
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 ...
40
votes
2
answers
9k
views
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 ...
40
votes
15
answers
17k
views
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 ...
38
votes
1
answer
12k
views
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 ...
37
votes
6
answers
35k
views
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?
36
votes
8
answers
24k
views
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 ...
36
votes
2
answers
43k
views
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 ...
35
votes
6
answers
42k
views
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];
...
33
votes
3
answers
44k
views
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 ...
33
votes
9
answers
19k
views
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 ...
32
votes
5
answers
16k
views
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 ...
31
votes
2
answers
17k
views
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 ...
29
votes
9
answers
20k
views
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 ...
29
votes
1
answer
7k
views
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 ...
29
votes
3
answers
8k
views
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
9
answers
35k
views
How To select a table row during a long press in Swift
I have a table which has a long press gesture recogniser that runs code depending on what table row is selected.
The trouble I'm having is that I currently have to tap the row I want then do the ...
27
votes
7
answers
41k
views
Detect when UIGestureRecognizer is up, down, left and right Cocos2d
I have a CCSprite that I want to move around using gestures. Problem is I'm completely new to Cocos2D. I want my sprite to perform one action when the gesture is up, another one when gesture is down, ...
27
votes
8
answers
17k
views
How do I capture the point initially tapped in a UIPanGestureRecognizer?
I have an app that lets the user trace lines on the screen. I am doing so by recording the points within a UIPanGestureRecognizer:
-(void)handlePanFrom:(UIPanGestureRecognizer *)recognizer
{
...
26
votes
4
answers
16k
views
How to have a UISwipeGestureRecognizer AND UIPanGestureRecognizer work on the same view
How would you setup the gesture recognizers so that you could have a UISwipeGestureRecognizer and a UIPanGestureRecognizer work at the same time? Such that if you touch and move quickly (quick swipe) ...
26
votes
3
answers
24k
views
How to add tap gesture to UICollectionView , while maintaining cell selection?
Task
Add a single tap gesture to UICollectionView, do not get in the way of cell selection.
I want some other taps on the no-cell part of the collectionView.
Code
Using XCode8, Swift 3.
override ...