스크롤 나는 사랑의 example for Multi-row selection과 같이, 각 행의 왼쪽에 체크 박스를 표시 layoutSubviews에 애니메이션을 시작하는 사용자 지정있는 UITableViewCell 만드는 작업이 포함되는 코코아를 구현했습니다 :있는 UITableViewCell 애니메이션
- (void)layoutSubviews
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationBeginsFromCurrentState:YES];
[super layoutSubviews];
if (((UITableView *)self.superview).isEditing)
{
CGRect contentFrame = self.contentView.frame;
contentFrame.origin.x = EDITING_HORIZONTAL_OFFSET;
self.contentView.frame = contentFrame;
}
else
{
CGRect contentFrame = self.contentView.frame;
contentFrame.origin.x = 0;
self.contentView.frame = contentFrame;
}
[UIView commitAnimations];
}
이 잘 작동을 모든 의향과 목적을 위해 내 UITableView는 필요한대로 동작합니다. 그러나 나는 작은 미적 문제에 직면하고있다. 이전에 표시되지 않은 UITableView 행을 스크롤하면 슬라이딩 애니메이션이 시작될 것이다. 즉, 애니메이션이 특정 행에 대해 시야에 비틀 거리는 것을 의미한다.
setAnimationBeginsFromCurrentState가 YES로 설정되어 있고 UITableView에서 더 아래쪽의 행이 아직 프레임 위치가 업데이트되지 않은 경우에 이해할 수 있습니다. 이 문제를 해결하기 위해 willDisplayCell을 사용하여 UITableView가 편집 모드에있는 동안 보이는 셀의 애니메이션을 재정의하려고했습니다. 기본적으로 애니메이션을 무시하고 셀이 이미 같은 장소로 애니메이션 한 것처럼 보이게하기 위해, 즉시 행 프레임을 업데이트 :
/*
Since we animate the editing transitions, we need to ensure that all animations are cancelled
when a cell is scheduled to appear, so that things happen instantly.
*/
- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
[cell.contentView.layer removeAllAnimations];
if(tableView.isEditing) {
CGRect contentFrame = cell.contentView.frame;
contentFrame.origin.x = EDITING_HORIZONTAL_OFFSET;
cell.contentView.frame = contentFrame;
} else {
CGRect contentFrame = cell.contentView.frame;
contentFrame.origin.x = 0;
cell.contentView.frame = contentFrame;
}
}
불행하게도이 어떤 영향을 미칠 것 같지 않습니다. 아무도 내가이 문제를 해결할 수있는 방법에 대한 아이디어가 있습니까?