Longpress or press and hold is a common gesture in which you touch the screen and hold for a couple of seconds instead of removing the finger immediately. The code for longpress is the same, except that it has a different recognizer associated with it. You also need to provide the duration after which the gesture is to be recognized.
There are no additional requirements needed, but you might want to test the duration that is most convenient through user testing.
We will add the following code in the
init function to initiate the longpress gesture recognizer. Here, along with the function, we will instruct that if a finger is pressed and held for more than 25 milliseconds, it needs to be considered a longpress. ...