-1

Here is my code for a long press. When I long-press the button, it keeps getting called. How do I set it up so it only gets called once and then gets called again only once the finger is release and the long press is started again?

    let tapGesture = UITapGestureRecognizer(target: self, action: #selector (tap))  
    let longGesture = UILongPressGestureRecognizer(target: self, action: #selector(long))  
    tapGesture.numberOfTapsRequired = 1

    self.reminderButton.addGestureRecognizer(tapGesture)
    self.reminderButton.addGestureRecognizer(longGesture)
Nevin Jethmalani
  • 2,726
  • 4
  • 23
  • 58

1 Answers1

0

use this code in your selector

@objc func gestureAction(gesture: UIGestureRecognizer) {
if let longPress = gesture as? UILongPressGestureRecognizer {
    if longPress.state == UIGestureRecognizer.State.began {

    } else {

    }
}
Nevin Jethmalani
  • 2,726
  • 4
  • 23
  • 58