Here is my code first:
@IBAction func SOSLongPressed(_ sender: UILongPressGestureRecognizer) {
//sender.numberOfTapsRequired = 2
sender.minimumPressDuration = 3
if sender.state == .began {
print("long pressed")
}
}
Problems:
"long pressed" is printed at around 0.5 (rather than 3) second after I started to press the view only for the first time after my app launched. In other words, after the app is launched, the UILongPressGestureRecognizer works properly for the 2nd or the 3rd (and so on) time, i.e., print "long pressed" after 3 seconds. But not for the first time.
If I uncomment the
sender.numberOfTapsRequired = 2
line, "long pressed" is also printed at around 0.5 second even with only 1 tap and hold. After that, even if I double tap and hold for 3 seconds, "long pressed" won't be printed out anymore.
No idea why is that and hope someone can help me out.
Thanks in advance!