0

カスタム アニメーションを UITableViewCells に追加しました。各セルには独自のアニメーションがあります。ビューをポップすると、アニメーションが続行され、アニメーションが割り当て解除されたセルにアクセスしようとしているため、不適切な実行エラーが発生します。

ビューの割り当てが解除される前にアニメーションを停止するにはどうすればよいですか?

- (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath {  
    self.Currentcell = [tableView cellForRowAtIndexPath:indexPath];
    [UIView beginAnimations:@"fade" context:nil];
    [UIView setAnimationDuration:0.4];
    [UIView setAnimationBeginsFromCurrentState:YES];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseIn];
    [self.Currentcell.accessoryView viewWithTag:1].alpha = 0;
    [self.Currentcell.accessoryView viewWithTag:2].alpha = 1;
    [UIView setAnimationDidStopSelector:@selector(animationEnded:finished:context:)];
    [UIView setAnimationDelegate:self];
    [UIView commitAnimations];
}

- (void)animationEnded:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {  
    [UIView beginAnimations:animationID context:context];
    [UIView setAnimationDuration:0.3];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
    [cell.accessoryView viewWithTag:1].alpha = 1;
    [cell.accessoryView viewWithTag:2].alpha = 0;
    [UIView commitAnimations];
}
4

2 に答える 2

1

このスレッドでは、commitAnimationsはビューを保持する必要があるため、アニメーションを実行しているときに割り当てを解除しないでください。多分あなたはどこかでビューを過剰に解放していますか?Build and Analyze(Xcode 3.2+ afaikで利用可能)は、それを見つけるのに役立つかもしれません。

于 2010-03-28T11:02:17.020 に答える
0

あなたのアニメーション コードがどのように見えるかはわかりません (投稿してもらえないでしょうか?)。基本的に、ビュー コントローラーに -viewWillDisappear: メソッドを実装し、そこで実行中のアニメーションを停止する必要があります。

于 2010-03-23T13:58:42.127 に答える