How would you program the Continuous Delete button?

I am making a calculator application and providing my own keyboard using UIButtons. I have a delete key, and everything works, except that the user needs to keep pressing the delete key again and again if they want to delete everything.

I was wondering if there is a way to delete everything when the button is held for more than 2 seconds.

+5
source share
3 answers

The easiest way to implement this would be to attach a long click gesture recognizer to your button [Delete].

Xcode . , IBOutlet , .

, , .

+4

-(IBAction)buttonHit {
    //here start timer that fires for every 2 seconds and handle deletion method in that
}

-(IBAction)buttonReleased {
   //Stop timer...
}
+2

All Articles