ios - continuously incrementing values of label by pressing the button -
(newbie in ios dev) main screen, screen .ccbi file , buttons images i've linked in code , implementing methods. doing when click plus button value increments 1 same on negative button case. each time i've click button increase/decrease value. want when press button values should keep increasing until un-touch button.? how can this? read somewhere done using cclayer touchbegin(); not find material me understanding mechanism. suggestions?
you can using timer , 2 ibactions.
declare timer , 2 ibaction like:
@property (nonatomic) nstimer *timer; - (ibaction)inc:(id)sender; - (ibaction)stop:(id)sender;
and implement method like:
- (ibaction)increment:(id)sender { _timer = [nstimer scheduledtimerwithtimeinterval:.1 target:self selector:@selector(inc) userinfo:nil repeats:yes]; } - (ibaction)stop:(id)sender { [_timer invalidate]; } - (void)inc { //increment , set text value here }
the important thing:
connect increment:
function touch down
event of uibutton
, stop:
function touch inside
event
Comments
Post a Comment