How to call a method when user keep pressing a button?
I know how to call a method when a button pressed.
but, My problem is when a user keep pressing a button it has to call one method
-(void)keeppressed { }
where as it has to call another method called
-(void)justpressed { }
when 开发者_如何学编程user just taps the button
is there any solution?
Write a method x
actually conatining the code you want to run, which is called from both.
There is UIGestureRecognizer which can handle taps and long presses. If this doesn't work for you (only available sind 3.2 IIRC), you should start a timer after the press and call keeppressed if it hasn't been released in meantime (wire up the actions for press and release / cancel).
精彩评论