0

これUITableViewCellは、左に画像を設定したテーブルにimageViewあります。ユーザーがセル(エイリアス行)を選択したときに、この画像を継続的に回転させるだけです。セルをアニメーション化しimageViewて回転させることはできますが、アニメーション化するとアプリケーションがユーザー入力に応答しなくなります。言い換えれば、アプリケーションがハングし、画像が本来あるべきように回転します。以下は、関連するコード スニペットです。

- (void)tableView:(UITableView *)aTableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//...
    [NSThread detachNewThreadSelector:@selector(rotateImage) toTarget:self withObject:nil];

//...
}

- (void) rotateImage {
    UITableViewCell *selectedCell = [self.tableView cellForRowAtIndexPath:[self.tableView indexPathForSelectedRow]];

    [UIView beginAnimations:@"looping animation" context:nil];
    // other animation options here if you'd like, and the duration can be anything, not just 3.

    [UIView animateWithDuration:10 delay:0 options:UIViewAnimationOptionRepeat animations: ^{
        // do your rotation stuff on your image, in this block, for the cell you will be returning.
        selectedCell.imageView.transform = CGAffineTransformMakeRotation(kDegreesToRadians(90));
    } completion:nil];

    [UIView commitAnimations];  
}

コード行にコメントするとNSThread、アプリケーションはハングしないので、基本的にはアニメーション コードで何か問題を起こしただけで、アプリがハング状態になりました。

4

1 に答える 1

1

ブロック アニメーションの (面倒な) デフォルトは、ユーザーの操作を無効にすることです。これを試して:

[UIView animateWithDuration:10 delay:0
                    options:UIViewAnimationOptionRepeat|UIViewAnimationOptionAllowUserInteraction
                 animations:^{
                    selectedCell.imageView.transform = CGAffineTransformMakeRotation(M_PI);
                }
                 completion:NULL];
于 2011-06-07T14:30:01.593 に答える