I have a UIButton
in my application and an action which is triggered when I TouchDown UIButton
.
Is it possible to detect a Touch-and-Hold on the UIButton
on the iPhone? I want my action to trigger when the user holds the button for 2 seconds or more.
Any Ideas?
UILongPressGestureRecognizer
is what you need. For example,To let your action get triggered only once(ie., when the 2 seconds duration is over), make sure you have your
doAction:
method looks something like this,On the other way you can use this NBTouchAndHoldButton. This is exactly what you want, and it is very easy to implement it:
Good luck!