Animation の開始と終了を受け取る方法
UIView の beginAnimation:context: を見ていると、どうもAnimationの開始と終了を受け取る事が出来るようで、それを試したメモ書き*1
まず、開始と終了時、メッセージを受け取るメソッド
- (void) setBeginAnimation:(id)sender { DLog(@"%s sender:%@", __FUNCTION__, sender); } - (void)setEndAnimation:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { DLog(@"%s animationID:%@ finished:%@ context:%x", __FUNCTION__, animationID, finished, context); }
アニメーション部分
[UIView beginAnimations:@"info.a-yasui.ipad.test.testapp" context:self]; // アニメーション開始メソッド [UIView setAnimationWillStartSelector:@selector(setBeginAnimation:)]; // アニメーション終了メソッド [UIView setAnimationDidStopSelector:@selector(setEndAnimation:finished:context:)]; // 通知先 [UIView setAnimationDelegate:self]; // 何かやましい事をたくさんして ... // 終了 [UIView commitAnimations];
でもってログはこんな感じ。これは長押しした時に、アクションが実行される感じ。longPressCellが二回あるけど、これは仕様なんです。UIGestureRecognizer の話なのでここでは割合。
2010-05-22 17:32:43.125 testapp[20197:207] -[iPadTestViewController longPressCell:] long press cell:0 2010-05-22 17:32:43.138 testapp[20197:207] -[iPadTestViewController(EachMessage) setBeginAnimation:] sender:jp.designegg.kisa.ipad.tailView.changeBackGroudColor 2010-05-22 17:32:43.338 testapp[20197:207] -[iPadTestViewController(EachMessage) setEndAnimation:finished:context:] animationID:info.a-yasui.ipad.test.testapp finished:1 context:5d2a200 2010-05-22 17:32:43.535 testapp[20197:207] -[iPadTestViewController longPressCell:] long press cell:0
*1:不思議な事に、あまり話題に上がってない。結構使いこなしたら便利だと思うんだけどなー