인터페이스 빌더에서 만든 사용자 정의 UITableViewCell이 있습니다. 나는 성공적으로 셀을 dequeuing하고 있지만 스크롤 할 때 셀은 다른 indexPath를 호출하기 시작하는 것처럼 보입니다. 이 예제에서는 현재 indexPath.section 및 indexPath.row를 customCellLabel에 제공하고 있습니다. 테이블을 위아래로 스크롤하면 일부 셀이 바뀝니다. 숫자는 모든 곳에있을 수 있지만 셀은 시각적으로 건너 뛰지 않습니다.스크롤하는 동안 사용자 정의 UITableViewCell이 indexPath를 변경합니까?
if (cell == nil)을 주석 처리하면 문제가 사라집니다.
표준 셀을 사용하면 문제가 해결됩니다.
왜 이런 일이 벌어지고 있을지 생각해보십시오.
// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"CalendarEventCell"];
if (cell == nil) {
NSLog(@"Creating New Cell !!!!!");
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CalendarEventCell" owner:self options:nil];
cell = (UITableViewCell *)[nib objectAtIndex:0];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
}
// Set up the cell...
[customCellLabel setText:[NSString stringWithFormat:@"%d - %d",indexPath.section, indexPath.row]];
return cell;
}
customCellLabel이란 무엇입니까? – jamesmoschou
customCellLabel은 Interface Builder에서 만든 CalendarEventCell에 포함 된 레이블입니다. – Chris