I am quite new to Swift and I am fascinated to the potential of distinguish these two gesture for a button.
I am writing my first app in xCode and I am near to conclude that. As a last step I want to implement two different actions for a button depending on a long press or a tap.
I have constructed the app as follows. I have several buttons connected to one IBAction and distinguished them using tags.
coming to the tag of the one of the two buttons on which I need the long press action I don't know how to continue.
Do you have some suggestion? Thank you so much
func longTap() {
if (resultDisplay.text != ""){
storedVariableA = String(result)
eraseAll()
}
}
else if (sender.tag == 20) {
let longPressGesture = UILongPressGestureRecognizer(target: self, action: #selector(self.longTap(_:)))
longPressGesture.minimumPressDuration = 2
sender.addGestureRecognizer(longPressGesture)
}