Привет, по моему мнению, используйте pangesture
var panGesture = UIPanGestureRecognizer()
//inSide viewDidLoad()
panGesture = UIPanGestureRecognizer(target: self, action: #selector(self.panGestureAction(_:)))
self.yourScrollview.addGestureRecognizer(panGesture)
//Create function like below
@objc func panGestureAction(_ gestureRecognizer : UIPanGestureRecognizer) {
guard gestureRecognizer.view != nil else {return}
let fileView = gestureRecognizer.view!
let directionVelocity = gestureRecognizer.velocity(in: myView)
let translation = gestureRecognizer.translation(in: self.view)
switch gestureRecognizer.state {
case .began :
break
case .changed:
if directionVelocity.x > 0 {
print("swipe right")
}
if directionVelocity.x < 0 {
print("swipe left")
}
if directionVelocity.y > 0 {
print("swipe down")
}
if directionVelocity.y < 0 {
print("swipe up")
}
break
case .ended :
print("end")
default:
break
}
}
Надеюсь, это поможет вам, спасибо.
Существует частичный ответ, так как эти зависимости Maven больше не доступны. Пожалуйста, обратитесь к этому блогу для альтернативного исправления.