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.
The easiest way to implement this would be to attach a long click gesture recognizer to your button [Delete].
[Delete]
Xcode . , IBOutlet , .
IBOutlet
, , .
-(IBAction)buttonHit { //here start timer that fires for every 2 seconds and handle deletion method in that } -(IBAction)buttonReleased { //Stop timer... }
UIButton "touchesBegan: withEvent:" UIResponder , , ( , "touchesEnded: withEvent" ).
touchesBegan: withEvent:
touchesEnded: withEvent