NSTimer IOS setting text of layer but text disappears once timer is destroyed -
NSTimer IOS setting text of layer but text disappears once timer is destroyed -
i'm using nstimer write text catextlayer text displays split second.
i set first timer this:
-(void) startsentanceanimation{ float firsttime = [[sentancearray objectatindex:0][@"time"]floatvalue]; [nstimer scheduledtimerwithtimeinterval:firsttime target:self selector:@selector(timedsentances:) userinfo:sentancearray repeats:no];
}
it calls method changes text , creates new timer.
-(void)timedsentances:(nstimer *)timer{ nsarray *userinfo = timer.userinfo; timer = nil; nsstring *sentance = [userinfo objectatindex:sentancecount][@"sentance"]; [self nextline:sentance]; //textlayer.string = sentance; float intervallength = [[userinfo objectatindex:sentancecount][@"time"]floatvalue]; [nstimer scheduledtimerwithtimeinterval:intervallength target:self selector:@selector(timedsentances:) userinfo:userinfo repeats:no]; sentancecount++; }
the code runs without error, , text displayed @ appropriate times, text flashes screen split sec , doesn't persist in between method calls. because i'm not keeping reference timer?
the text should set using method nextline follows:
-(void)nextline:(nsstring *)st{ textlayer.string = st;
}
the textlayer catextlayer , declared variable in interface this:
@interface icirecorddetail(){ catextlayer *textlayer; }
and instantiated in viewdidload method.
i've tried setting text this:
[textlayer settext:sentance];
but same thing happens. sentance appears when timer fires, , disappears again. i'm wondering because in catextlayer? new ios @ loss. help great. thanks
ios nstimer catextlayer
Comments
Post a Comment