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
1
vote
1 answer

Building a 3D cube in iOS with two gestures

I can programmatically create a 3D cube in iOS using the code below. However, I need to use gestures to define its size. With a pinch gesture I'd like to build a base of cube in XZ axis. And with a drag gesture I'd like to build a height of cube in…
Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
1
vote
1 answer

ios: How to make UIPickerView(UIView) catch touch event before UITouchRecognizer?

Event Handling Guide for iOS said "There may be times when you want a view to receive a touch before a gesture recognizer. ", but I couldn't find how to do that. I tried delaysTouchesEnded = false, but it does not have any effect. @IBOutlet weak var…
1
vote
1 answer

Gesture recognizer code being called twice after leaving and coming back to view

I've got buttons I'm creating on my view when the page is loaded. In my viewDidAppear I've got NotificationCenter.default.addObserver(self, selector: #selector(self.didDoubleTapOnACircle(sender:)), name: .didDoubleTap , object: nil) These are…
user6820041
  • 1,213
  • 2
  • 13
  • 29
1
vote
0 answers

Swift Target not fireing when called from another class

I am trying to create a image swift class/file and then add it to the view in another class...it has gestures attached to it programmatically using addTarget class GestureCreate: UIImageView,UIGestureRecognizerDelegate { init(){ let imageName =…
1
vote
3 answers

UIGestureRecognizer crashes on < OS3.2

This is to be expected but I can't seem to find a runtime that works properly as it seems it was a private API before!!!! At the moment I have and OS3.1.3 responds to the addGestureRecognizer selector!!!! if ( [self.view…
Lee Armstrong
  • 11,420
  • 15
  • 74
  • 122
1
vote
3 answers

How to set 'enabled' property for gesture recognizers in Swift 3

I can't set the 'enabled' property with gesture recognizers. I tried creating recognizers both programmatically and by adding an @IBAction in Xcode and connecting it by control drag to the code. I try to use properties like…
Anton Platonov
  • 379
  • 4
  • 15
1
vote
0 answers

handling different gestures on different UIViews in same point

I have two views in the same location on screen. The top view should handle pan gesture and the bottom should handle TouchUpInside. I'm only getting the panning gesture event and not the TouchUpInside event. I read about Hit-testing so i understand…
ilan
  • 4,402
  • 6
  • 40
  • 76
1
vote
3 answers

How to make particular location is clickable in UiLabel in UITableView?

I'm having a UITabelView in that I'm having a UILabel. UILabel will be populated with different text contents with one Email id(all mail id's are same). I want to make this Email id clickable. So far I have done is I highlight this email id with…
e.k
  • 1,333
  • 1
  • 17
  • 36
1
vote
1 answer

Prevent multiple pan gestures in custom UITableViewCells

I have a table view displaying custom table view cells. Each cell has a pan gesture recognizer to allow a view to be swiped left and right. Currently a user can swipe multiple cells simultaneously which is not desired behavior. I'd like to prevent…
1
vote
2 answers

Bound the movement of a view which is added to UIPanGestureRecognizer, within its superview

I want to know if there is a way to bound the movement of my UIView within its superview while using GestureRecognizer. eg. I have a UIImageview To whom I add UIPanGestureRecognizer with action panPiece. I adjust its center in the following way to…
rkb
  • 10,933
  • 22
  • 76
  • 103
1
vote
1 answer

iOS How do I tell when a user is interacting with the app?

Goal: I need to be able to tell when a user is interacting with an iPhone app. After 5 minutes, I will auto logout the user, but I don't want to do that if the user is interacting with the app. I have read about shouldReceiveTouch:, but that it will…
flhhc
  • 19
  • 4
1
vote
1 answer

UIPanGesture is Working but UITapGesture Is not Working on UIView

I have a small view that I want to be moved around the screen and tapable. So I add a UIPanGestureRecognizer to move it, and a UITapGestureRecognizer to receive tap events like so: let panner = UIPanGestureRecognizer(target: self, action:…
1
vote
1 answer

Recognize swipe gesture in UIScrollView only when scrolling content reach the edge

I have UIScrollView with vertical scroll active. What I am trying to do is to add a swipe gesture with direction .down which will be recognized when the user cannot scroll the content anymore because it reaches the edge. I was trying with…
1
vote
1 answer

Slide in/out child view controller partially visible on parent view controller in Swift

I have built two separate UIViewControllers: MainVC and 2ndVC. Now I am trying to connect them and achieve the effect presented on the image below: When loaded, 2ndVC should be visible partially on top of MainVC (let's say 1/4 of the screen). On…
Bastek
  • 899
  • 1
  • 12
  • 27
1
vote
1 answer

Swift 3: UIScrollView and (disabling) Gesture Recognizers

I'm in swift 3 and I have a class that's a subclass of UIScrollView. Here it is: import SpriteKit /// Scroll direction enum ScrollDirection { case vertical case horizontal } class CustomScrollView: UIScrollView { // MARK: - Static…
Jean Valjean
  • 747
  • 1
  • 9
  • 30