複数をループしてそれぞれにアニメーションを実行しようとしていますUIViews
が、すべてのアニメーションがいつ終了したかを知りたいです。アニメーションのループが終了したときに関数を呼び出す最良の方法は何ですか? 代わりに、すべてが完了するまで待つ方法はありますか?
を使ってみsetAnimationDidStopSelector
ましたが、起動しません。この場合、ゲーム ボードからいくつかの「チップ」をフェードアウトさせてから削除します (NumberedChipView は UIView のサブクラスです)。チップがボードから離れるまで、プレイを続けることはできません。
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDelegate: self];
[UIView setAnimationDidStopSelector:@selector(animationDidStop)];
// clear chips
for (HexagonalTile *aTile in tilesToClear) {
NumberedChipView *chipView = [self chipViewForColumn:aTile.column andRow:aTile.row];
[UIView animateWithDuration:0.5 delay:0.3 options:UIViewAnimationCurveLinear animations:^{
chipView.alpha = 0.0;
}
completion:^(BOOL finished){
if (finished) {
[chipView removeFromSuperview];
[self.chipViews removeObject:chipView];
}
}];
}
[UIView commitAnimations];
私もCATransaction
無駄にしようとしました:
[CATransaction begin];
[CATransaction setCompletionBlock:^{
[self animationFinished];
}];
// clear chips
for (HexagonalTile *aTile in tilesToClear) {
NumberedChipView *chipView = [self chipViewForColumn:aTile.column andRow:aTile.row];
[UIView animateWithDuration:0.5 delay:0.3 options:UIViewAnimationCurveLinear animations:^{
chipView.alpha = 0.0;
}
completion:^(BOOL finished){
if (finished) {
[chipView removeFromSuperview];
[self.chipViews removeObject:chipView];
//NSLog(@"clearing finished");
}
}];
}
[CATransaction commit];
アップデート:
セレクターを起動できるようになりましたが、アニメーションのループが終了するのを待ちません。
[UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:)];