views:

18

answers:

2

Hi All,

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?

+2  A: 

Write a method x actually conatining the code you want to run, which is called from both.

FUZxxl
actually the keeppressing method should not call when tapping on that button. it should call when user keep pressing have any idea on this?
Ganesh
and we should not use touch events here..this is the issue.
Ganesh
But, obviously the function `keeppressed` does exactly this.
FUZxxl
A: 

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).

Eiko