ios - Display seconds in a UILabel from a NSTimer which was selected from UIPickerView -
how can display number of seconds in label nstimer?
imagevc.h @property (weak, nonatomic) iboutlet uilabel *timelabel; imagevc.m -(void)viewdidappear:(bool)animated { [super viewdidappear:animated]; imageviewcontroller *pickerview = [[imageviewcontroller alloc] init]; [nstimer scheduledtimerwithtimeinterval:10 target:self selector:@selector(timeout) userinfo:nil repeats:no]; }]; } }
any appreciated.
thanks
add timer 1 second interval updates label
-(void)viewdidappear:(bool)animated { [super viewdidappear:animated]; imageviewcontroller *pickerview = [[imageviewcontroller alloc] init]; [nstimer scheduledtimerwithtimeinterval:10 target:self selector:@selector(timeout) userinfo:nil repeats:no]; [nstimer scheduledtimerwithtimeinterval:1 target:self selector:@selector(settimetolabel) userinfo:nil repeats:no]; } - (void)settimetolabel { counterprivatevar += 1; self.lbl.text = [nsstring stringwithformat:@"%d", counter]; }
Comments
Post a Comment