0
工作我做了一个自定义的UIControl它使用UIControlEvents
来识别特定的相互作用。它的工作都很好。现在,我也希望我的UIControl来识别UIPanGestureRecognizer
,这里的代码UIPanGestureRecognizer不UIControlEvents
fieldView.addTarget(self, action: #selector(willSelectField(sender:)), for: .touchDown)
fieldView.addTarget(self, action: #selector(didSelectField(sender:)), for: .touchUpInside)
fieldView.addTarget(self, action: #selector(canceledFieldSelection(sender:)), for: .touchUpOutside)
fieldView.addGestureRecognizer(UIPanGestureRecognizer(target: self, action: #selector(draggingField(gesture:))))
所以,当我点击我的的FieldView(定制UIControl)touchDown
将被识别。如果我不开始平移,touchUpInside
和touchUpOutside
也将得到认可。但是,如果我和平移例如放开我的FieldView外,touchUpOutside
不会被触发。
注:touchDragInside
不是一个选择,因为它只能识别一个范围内的大约100像素内拖动。
我尝试过,但在'touchesCancelled'方法不会被调用,我也不能找到一种方法touchUpInside'或'touchUpOutside'之间'这个方法来区分 – Codey