これ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
、アプリケーションはハングしないので、基本的にはアニメーション コードで何か問題を起こしただけで、アプリがハング状態になりました。