0

In my app, there is a scrollView(pageScrollView) which is a snapchat like interface (https://www.youtube.com/watch?v=1_daE3IL_1s)

However, when I try to use below code to get the gesture on the scroll view, it cannot detect, can anyone help me on this??

let leftSwipeGesture = UISwipeGestureRecognizer(target: self, action: #selector(leftSwipedByUser(_:)))
leftSwipeGesture.direction = .left
self.pageScrollView.addGestureRecognizer(leftSwipeGesture)


let rightSwipeGesture = UISwipeGestureRecognizer(target: self, action: #selector(rightSwipedByUser(_:)))
rightSwipeGesture.direction = .right
self.pageScrollView.addGestureRecognizer(rightSwipeGesture)

And the action is below:

@objc func leftSwipedByUser(_ gesture:UISwipeGestureRecognizer) {
    print("left swipe")
}
@objc func rightSwipedByUser(_ gesture:UISwipeGestureRecognizer) {
    print("right swipe")
}
Roman Podymov
  • 4,168
  • 4
  • 30
  • 57
ytsm
  • 21
  • 5

0 Answers0