ios - NSDate doesn't refresh -
the nsdate in first view controller wont refresh until go view controller , come it. idea why be?
viewdidload:
nstimer *timer = [nstimer scheduledtimerwithtimeinterval:1.0 target:self selector:@selector(fadein) userinfo:nil repeats:no]; [timer fire];
viewwillappear:
// date nsdateformatter *formatter = [[nsdateformatter alloc] init]; [formatter setdatestyle:nsdateformatterfullstyle]; nsstring *datetoday = [formatter stringfromdate:[nsdate date]]; [datelabel settext:datetoday]; datelabel.font = [uifont fontwithname:@"helvetica-bold" size:12];
method:
-(void) fadein { datelabel.alpha = 0; [uiview beginanimations:nil context:nil]; [uiview setanimationdelay:1.0]; [uiview setanimationcurve:uiviewanimationcurveeasein]; [uiview setanimationdelegate:self]; [uiview setanimationduration:1.0]; datelabel.alpha = 1; [uiview setanimationdidstopselector:@selector(animationdidstop:finished:context:)]; [uiview commitanimations]; }
thanks!
edit: problem solved, people below helpful answers. looks other people didn't give answers closed question, both people gave answers below worked!
what @hotlicks saying fadein
fine changing uilabel
new date? need show changed date right?
-(void) fadein { //just example. change format in showing date. nsdate *date = [nsdate date]; nsdateformatter *dateformat = [[nsdateformatter alloc] init]; [dateformat setdateformat:@"yyyy"]; uilabeldate.text = [dateformat stringfromdate:date]; .... }
update: worked @reez - oh have got now. not idea put such functions in viewwillappear
view cached , method not called. better put method in viewdidload
. see if works...
Comments
Post a Comment