UILongPressGestureRecognizer状态。直到触摸后才被调用

时间:2019-04-10 18:35:32

标签: ios swift uigesturerecognizer

我在同一视图中添加了UILongPressGestureRecognizerUIPanGestureRecognizer。我实现了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
    } 
}

0 个答案:

没有答案