0

I wanna make a layer rotate and the code is like this :

weightHand.bounds = CGRectMake(0,0,w,h);
weightHand.anchorPoint = CGPointMake(GET_COEFF(QCETEK_WHAT_UNITS, WEIGHTHANDE_APX_INDEX),
                                     GET_COEFF(QCETEK_WHAT_UNITS, WEIGHTHANDE_APY_INDEX));

weightHand.transform = CATransform3DMakeRotation (SCALE_INIT_DEGREE , 0, 0, 1);

With the code , the weightHand truly rotates. But now I wanna know when the rotation animation is done. I hope to continue to rotate it when the previous rotation is completed.

I suppose there might be some delegate that can be invoked at the right time during the procedure of the animation , saying beginning or done .

Please help to enlighten me on the information. Thanks a lot. [edited]:Code is pasted.

if ( !bStopped ) {
    [data_queue addObject:[NSNumber numberWithDouble:dbWeight]] ;
    NSLog(@"Qu") ;

}
else {
    NSLog(@"Con") ;

}

bStopped = NO  ;
[UIView animateWithDuration:1 animations:^{


     weightHand.transform = CATransform3DMakeRotation (CONVERT_TO_DISPLAY_FROM_KG(dbWeight), 0, 0, 1);

} completion:^(BOOL finished) {
    if ( finished ) {
        NSLog(@"Done") ;
        bStopped = YES ;
        if ( [data_queue count] == 0 ) return ;
        double dbLocalWeight = [[data_queue objectAtIndex:0] doubleValue];
        [data_queue removeObjectAtIndex:0];
        [self setMainAnimation:dbLocalWeight] ;
    }
}];

the log is like this: 2013-12-05 22:10:49.524 Scale_Lite[969:60b] Con 2013-12-05 22:10:49.530 Scale_Lite[969:60b] Done 2013-12-05 22:10:49.674 Scale_Lite[969:60b] Con 2013-12-05 22:10:49.680 Scale_Lite[969:60b] Done 2013-12-05 22:10:49.724 Scale_Lite[969:60b] Con 2013-12-05 22:10:49.730 Scale_Lite[969:60b] Done 2013-12-05 22:10:49.924 Scale_Lite[969:60b] Con 2013-12-05 22:10:49.930 Scale_Lite[969:60b] Done


user1338624
  • 174
  • 1
  • 10
  • try this one: http://stackoverflow.com/questions/8494184/ios-uiview-animation-catransform3dmakerotation-confusion – ElizaS Dec 05 '13 at 12:36
  • One more question on the parameter :animateWithDuration . It seems not make effect even if it is set 10s . the animation is "completed" in very short time. the code/Log are added in the main thread . – user1338624 Dec 05 '13 at 14:21
  • I have found out the solution . change the weightHand from layer to UIView . then above code works. – user1338624 Dec 06 '13 at 02:09

0 Answers0