0

Is there a way to pickup all UIGestureRecognizer events in one method? (besides via directing all their selectors to the same method).

So for example:

    // Add Gesture Recogniser (Long Press)
    let longPressGR = UILongPressGestureRecognizer(target: self, action: #selector(GcMapView.longPressAction(_:)))
    longPressGR.minimumPressDuration = 1
    self.addGestureRecognizer(longPressGR)

    // Add Gesture Recogniser (Pan)
    let mapDragRecognizer =  UIPanGestureRecognizer(target: self, action: #selector(GcMapView.panAction(_:)))
    mapDragRecognizer.delegate = self
    self.addGestureRecognizer(mapDragRecognizer)

    // Add Gesture Recogniser (Pinch)
    let pinchGestureRecogniser =  UIPanGestureRecognizer(target: self, action: #selector(GcMapView.pinchAction(_:)))
    pinchGestureRecogniser.delegate = self
    self.addGestureRecognizer(pinchGestureRecogniser)    

   // SOME METHOD NOW TO PICKUP ALL EVENTS
   func PICKUPALLEVENTS (sender:UIGestureRecognizer) {
       print("(String(gestureRecognizer.dynamicType) - \(gestureRecognizer.state.hashValue) ")
   }  
Greg
  • 34,042
  • 79
  • 253
  • 454
  • Please explain what you mean by "pickup". What information do you want that you could not get by making all of the gesture recognizers call the same action? – Kurt Revis Jun 18 '16 at 23:01
  • the info in the PICKUPALLEVENTS function (see above) – Greg Jun 18 '16 at 23:03
  • In a single action method, couldn't you keep an instance variable for each gesture recognizer, or iterate through `self.gestureRecognizers`, and call `dynamicType` and `state.hash` on each? – Kurt Revis Jun 18 '16 at 23:11
  • could - but I was interested in knowing if there was a method/callback that did what I've asked that I was missing – Greg Jun 18 '16 at 23:16

2 Answers2

2

No, I don't think there is any way to do that.

Duncan C
  • 128,072
  • 22
  • 173
  • 272
0

Have you tried adding a UIGestureRecognizer to your target, then checking the dynamic type of the UIGestureRecognizer in the selector called?

JoeVictor
  • 1,806
  • 1
  • 17
  • 38