在回调中获取所有 UIGestureRecognizer 事件?
pick up all UIGestureRecognizer events in callback?
有没有办法在一种方法中获取所有 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) ")
}
不,我认为没有办法做到这一点。
您是否尝试过向目标添加 UIGestureRecognizer
,然后在调用的选择器中检查 UIGestureRecognizer
的动态类型?
有没有办法在一种方法中获取所有 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) ")
}
不,我认为没有办法做到这一点。
您是否尝试过向目标添加 UIGestureRecognizer
,然后在调用的选择器中检查 UIGestureRecognizer
的动态类型?