アニメーションに名前を付けることができます(各ビューには一意のアニメーション名が必要です)。
[UIView beginAnimations:@"myAnimation" context:nil];
myView.alpha = 1.0f; // or whatever property you're animating...
[UIView commitAnimations];
次に、この名前をで取得します
- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(id)context
{
if ([finished boolValue])
{
if ([animationID isEqualToString:@"myAnimation"])
[myView removeFromSuperview];
}
}
さらに良いことに、iOS4 +ブロックアニメーションメソッドとその完了ハンドラーを使用すると、完了ハンドラーでアニメーション化されているビューをはるかにきれいに参照できるようになります。例えば
[UIView animateWithDuration:0.4f animations:^
{
myView.alpha=1.0f;
}
completion:^(BOOL finished)
{
[myView removeFromSuperview];
}];