我在同一视图中添加了UILongPressGestureRecognizer
和UIPanGestureRecognizer
。我实现了shouldBeRequiredToFailBy
,以确保只有在平移手势失败时才调用longPress。
我遇到的问题是在我按下之前,不会在longPressGesture上调用.began
状态。不知道它在哪里被劫持。有什么想法吗?
func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer,
shouldBeRequiredToFailBy otherGestureRecognizer: UIGestureRecognizer) -> Bool {
// Do not begin the rotation until the tap fails.
if gestureRecognizer == self.rotationGesture &&
otherGestureRecognizer == self.switchOutfitTapGesture {
return true
}
return false
}
@objc func sceneTapped(rec: UILongPressGestureRecognizer) {
if (rec.state == .began) {
//not called till finger lifts up
}
}