iphone - Moving an object without animating it in an animation block -


i'm animating bunch of buttons move left of screen should magically move right of screen. calling:

[nstimer scheduledtimerwithtimeinterval:0.20 target:self selector:@selector(movethebuttons) userinfo:nil repeats:yes]; 

in viewdidload.

they animate quite happily left, animate right. want them disappear , reappear right-off-screen. because i'm new assumed since after commitanimations call wouldn't animate. think problem animations 'commit' after movethebuttons function returns, can't think of elegant (or standard) way around this.

how move uibutton off screen without animating it, preferably still in movethebuttons function?

as can infer, i'm new animations on iphone, if see other mistakes i'm making feel free give me pointers.

-(void)movethebuttons{ nslog(@"movethebuttons");  [uiview beginanimations:@"mov-ey" context:clouda]; [uiview setanimationduration: .20]; [uiview setanimationcurve:uiviewanimationcurvelinear]; clouda.center = cgpointmake(clouda.center.x-pos.x,clouda.center.y); [uiview commitanimations];   if(clouda.center.x < -100){     //i don't want animate bit.      clouda.center = cgpointmake(550,clouda.center.y); }  //nslog(@"clouda.center.x %f", clouda.center.x); } 

precalculate point , invert order , return before animating block.

you unconditionally committing animation engine in cases.

-(void)movethebuttons{ nslog(@"movethebuttons");  cgpoint mypoint = cgpointmake(clouda.center.x-pos.x,clouda.center.y);  if(clouda.center.x < -100){     //i don't want animate bit.      clouda.center = cgpointmake(550,clouda.center.y);     return; }   [uiview beginanimations:@"mov-ey" context:clouda]; [uiview setanimationduration: .20]; [uiview setanimationcurve:uiviewanimationcurvelinear]; clouda.center = mypoint; [uiview commitanimations];  } 

theres style point using return rather if/else can form own opinion.

cheers


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -