ios - UIView animation happening immediately -
i have animation of 3 buttons used work until added different possible positions buttons. animation happens immediately, i'm not sure why.
here's code:
defaults=[nsuserdefaults standarduserdefaults]; _btncuenta3.hidden=no; cgpoint newposition2; cgpoint newposition3; cgpoint newpositionagregar; if([defaults objectforkey:@"cuenta3"]){ newposition2=cgpointmake(200.0f + _btncuenta2.frame.size.width/2.0f, _btncuenta2.center.y); newposition3=cgpointmake(165.0f + _btncuenta3.frame.size.width/2.0f, _btncuenta3.center.y); newpositionagregar=cgpointmake(130.0f + _btnagregar.frame.size.width/2.0f, _btnagregar.center.y); _btncuenta2.center=newposition2; _btncuenta3.center=newposition3; _btnagregar.center=newpositionagregar; }else if([defaults objectforkey:@"cuenta2"]){ newposition2=cgpointmake(200.0f + _btncuenta2.frame.size.width/2.0f, _btncuenta2.center.y); newpositionagregar=cgpointmake(165.0f + _btnagregar.frame.size.width/2.0f, _btnagregar.center.y); _btncuenta2.center=newposition2; _btnagregar.center=newpositionagregar; }else{ newpositionagregar=cgpointmake(200.0f + _btnagregar.frame.size.width/2.0f, _btnagregar.center.y); _btnagregar.center=newpositionagregar; } [uiview beginanimations:nil context:nil]; [uiview setanimationduration:1.0f]; [uiview commitanimations];
any idea why it's happening or how can fix it?
i think [uiview beginanimations:nil context:nil];
should first line before doing changes uiview contents.
code:
[uiview beginanimations:nil context:nil]; [uiview setanimationduration:1.0f]; //view changes code [uiview commitanimations];
Comments
Post a Comment