Je cours ce code pour redimensionner et déplacer une image dans l'animation. Cela fonctionne parfaitement la première fois, mais la prochaine fois que j'utilise ce code, l'image ne s'anime pas. J'ai mis des instructions NSLog avant et après les transformations pour voir si l'image est affectée. Voir les résultats ci-dessous le codeL'animation ne fonctionne pas lors de la deuxième exécution
-(void)animateShowImage:(UIButton *)button
{
//set the starting animate position
CGRect frameRect = imageView.frame;
frameRect.size.width = button.frame.size.width;
frameRect.size.height = button.frame.size.height;
frameRect.origin = button.frame.origin;
imageView.frame = frameRect;
NSLog(@"imageview width : %f", imageView.frame.size.width);
NSLog(@"imageview height : %f", imageView.frame.size.height);
NSLog(@"imageview x : %f", imageView.frame.origin.x);
NSLog(@"imageview y : %f", imageView.frame.origin.y);
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:1.2];
CGAffineTransform move = CGAffineTransformMakeTranslation(30, 20);
CGAffineTransform scale = CGAffineTransformMakeScale(3,3);
CGAffineTransform finalTransform = CGAffineTransformConcat(move, scale);
imageView.transform = finalTransform;
[UIView commitAnimations];
NSLog(@"imageview width : %f", imageView.frame.size.width);
NSLog(@"imageview height : %f", imageView.frame.size.height);
NSLog(@"imageview x : %f", imageView.frame.origin.x);
NSLog(@"imageview y : %f", imageView.frame.origin.y);
}
NSLog première manche:
2009-10-19 19:13:41.339 MyProject[15847:207] imageview width : 48.000000
2009-10-19 19:13:41.341 MyProject[15847:207] imageview height : 45.000000
2009-10-19 19:13:41.341 MyProject[15847:207] imageview x : 8.000000
2009-10-19 19:13:41.342 MyProject[15847:207] imageview y : 57.000000
(gdb) continue
Current language: auto; currently objective-c
2009-10-19 19:13:44.649 MyProject[15847:207] imageview width : 144.000000
2009-10-19 19:13:44.650 MyProject[15847:207] imageview height : 135.000000
2009-10-19 19:13:44.650 MyProject[15847:207] imageview x : 50.000000
2009-10-19 19:13:45.080 MyProject[15847:207] imageview y : 72.000000
NSLog deuxième manche:
2009-10-19 19:13:51.487 MyProject[15847:207] imageview width : 48.000000
2009-10-19 19:13:51.488 MyProject[15847:207] imageview height : 45.000000
2009-10-19 19:13:51.489 MyProject[15847:207] imageview x : 8.000000
2009-10-19 19:13:51.489 MyProject[15847:207] imageview y : 57.000000
(gdb) continue
2009-10-19 19:13:54.424 MyProject[15847:207] imageview width : 48.000000
2009-10-19 19:13:54.425 MyProject[15847:207] imageview height : 45.000000
2009-10-19 19:13:54.425 MyProject[15847:207] imageview x : 8.000000
2009-10-19 19:13:57.433 MyProject[15847:207] imageview y : 57.000000
Je ne peux pas comprendre ce que je suis fait mal. Toute aide est appreciee!
Veuillez ajouter votre problème en ligne. –
@Georg - vous avez 18k réputation - vous pouvez l'éditer vous-même;) – deanWombourne
Merci @Georg @deanWomBourne – yanguango