0

如何在同一 View-iOS 上检测 UISwipeGestureRecognizer 2 手指滑动或 3 手指滑动

有人知道吗?

4

2 回答 2

6

我已经为 2 和 3 指滑动创建了一个手势。

       func addTwoFingerSwipeGesture() {
            let gesture = UISwipeGestureRecognizer(target: self, action: "handleTwoFingerSwipe")
            gesture.direction = .Left
            gesture.numberOfTouchesRequired = 2 // 2 finger swipe
            self.view.addGestureRecognizer(gesture)
        }

       func addThreeFingerSwipeGesture() {
            let gesture = UISwipeGestureRecognizer(target: self, action: "handleThreeFingerSwipe")
            gesture.direction = .Left
            gesture.numberOfTouchesRequired = 3 // 3 finger swipe
            self.view.addGestureRecognizer(gesture)
        }


    // Handle Swipe
        func handleTwoFingerSwipe() {
            print("2 finger swipe recognized")
        }

        func handleThreeFingerSwipe() {
            print("3 finger swipe recognized")
        }
于 2016-08-26T10:12:35.820 回答
2

这里的“setMinimumNumberOfTouches”取决于你的手指(例如:2/3/4/5)。尝试一次..它可能对你有帮助

  UIPanGestureRecognizer *pan;
 pan = [[UIPanGestureRecognizer alloc] initWithTarget:self     action:@selector(Swipe4ScrollViews:)];
[pan setMinimumNumberOfTouches:2];
 [_scroll1 addGestureRecognizer:pan];
  [pan release];
于 2012-01-02T10:00:42.167 回答