在回调中获取所有UIGestureRecognizer事件?

时间:2016-06-18 22:58:05

标签: ios uigesturerecognizer uipangesturerecognizer uitapgesturerecognizer uipinchgesturerecognizer

有没有办法在一种方法中拾取所有UIGestureRecognizer事件? (除了通过将所有选择器指向相同的方法)。

例如:

    // 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) ")
   }  

2 个答案:

答案 0 :(得分:2)

不,我认为没有办法做到这一点。

答案 1 :(得分:0)

您是否尝试向目标添加UIGestureRecognizer,然后检查名为?的选择器中UIGestureRecognizer的动态类型?