0
런타임시 프로그래밍 방식으로 셀에 추가하는 UIImageView를 사용하여 모든 사용자 정의 하단 경계선을 모든 tableview 셀에 추가하려고합니다. 문제는 사용자가 스크롤 할 때 테두리가 무작위로 사라질 수 있다는 것입니다. 존재하는 경우동적으로 UITableViewCell에 테두리 보조 추가하기
UIImageView* border = (UIImageView*)[cell viewWithTag:10];
if (border)
[border removeFromSuperview];
NSInteger sectionRows = [tableView numberOfRowsInSection:[indexPath section]];
NSInteger row = indexPath.row;
if (row != sectionRows - 1) {
UIImageView* border = [[UIImageView alloc] initWithImage:[[ImageManager sharedManager] imageNamed:@"dashed_border"]];
[border setFrame:CGRectMake(10, [self tableView:tableView heightForRowAtIndexPath:indexPath], 290, 1)];
[border setTag:10];
[cell addSubview:border];
[border release];
}
그것은 국경 서브 뷰를 제거하고 행은 맨 아래 행이없는 경우,이 행의 하단 테두리를 삽입합니다
이 코드는 내 cellForRowAtIndexPath 방법입니다.
이것이 경쟁 조건인지 또는 사용자가 스크롤 할 때 cellForRowAtIndexPath가 호출되지 않는 특정 시간이 있는지 확실하지 않습니다.
섹션의 행 수가 변경됩니까? – smparkes
그리고 무엇을 하든지 항상 가장 일반적인 경우 인 것처럼 보더를 제거하고 다시 추가하지 않는 것이 좋습니다. 대신, 거기에 있고 마지막 행에있는 경우에만 제거하십시오. 일반적으로 그다지 간단하지는 않지만 테이블 뷰 셀에서는 필요없는 작업을하고 싶지 않습니다. – smparkes
아니요, 행의 수는 콜렉션의 항목 수에 따라 설정됩니다. – James