0
我正在運行此代碼來縮放和移動動畫中的圖像。它在第一次運行中完美運行,但下一次運行此代碼時,圖像不會生成動畫。 我已經在變換之前和之後放置NSLog語句,以查看圖像是否受到影響。請參見下面的代碼,結果第二次運行時動畫不起作用
-(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首輪:
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第二次運行:
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
我不能想出什麼I'm做錯了。任何幫助是apprechiated!
請在線添加您的問題。 – 2010-11-09 12:40:03
@Georg - 你有18k的聲望 - 你可以自己編輯它) – deanWombourne 2010-11-09 12:47:05
謝謝@Georg @deanWomBourne – yanguango 2010-11-09 12:49:10