How would you program a Continuous Delete Button?

ios, iphone, uibutton, xcode

Solution

The simplest way of implementing this would be attaching a long press gesture recognizer to your `[Delete]` button.

Xcode lets you attach long press gesture recognizer in the interface builder. Add it to your button, configure the duration of long press, and connect the handler to `IBOutlet` in the same way that you connect other UI events.

If you would rather do it in code, this answer shows you how.

Problem

I'm making a calculator app and am supplying my own keypad with UIButtons. I have a delete key and everything works except that the user has to keep pressing the delete key over and over again if they want to delete all. I was wondering if there is a way to delete everything when the button is held for more than 2 seconds.

Original source

Related problems