[indexPath 행] 및 스크롤에 대해 다른 질문이 많이 있지만 이상한 숫자가 왜 반환되는지 이해할 수있는 사람이 누구인지 알고 있습니까? 로드 될 때cellForRowAtIndexPath - 스크롤 할 때 이상한 숫자를 반환하는 [indexPath 행]
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"ProfileIdentifier";
NSUInteger row = [indexPath row];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell == nil){
//My custom xib file is named "ProfileCell.xib"
[[NSBundle mainBundle] loadNibNamed:@"ProfileCell" owner:self options:nil];
cell = profileCell;
self.profileCell = nil;
}
//name and info are both of type NSArray
labelName.text = [name objectAtIndex:row];
labelInfo.text = [info objectAtIndex:row];
NSLog(@"Row: %d", row);
return cell;
}
콘솔이 반환됩니다 :
2012년 8월 26일 09 : 09 : 나는 내 세포를 구성하는 방식에 대한 해결 방법을 알아낼 수 없습니다 10.966 탐색 [ 8028 : F803] 행 0
2012년 8월 26일 09 : 09 : 10.983 탐색 [8028 : F803] 행 1
2012년 8월 26일 09 : 09 : 10.986 탐색 [8028 : F803] 행 : 2
2012-08-26 09 : 09 : 10.996 Nav [8028 : f803 ] 행 3
2012년 8월 26일 09 : 09 : 10.999 탐색 [8028 : F803] 행 4
2012년 8월 26일 09 : 09 : 11.002 탐색 [8028 : F803] 행 5 09 :
2012년 8월 26일 09
탐색 11.004 [8028 : F803] 행 62012년 8월 26일 09 : 09 : 11.007 탐색 [8028 : F803] 행 7
2012-08-26 09 : 09 : 11.010 탐색 [8028 : f803] 행 : 8
2012-08-26 09 : 09 : 11.012 탐색 [8
2012년 8월 26일 09 : 09 : 12.354 탐색 [8028 : F803] 행 3
028 : F803] 행 : I 셀 오프 스크린으로 스크롤 할 때 9은 그러므로이 반환
2012년 8월 26일 09 : 09 : 12.404 탐색 [8028 : F803] 행 2
2012년 8월 26일 09 : 09 : 12.471 탐색 [8028 : F803] 행 1
2012-08 -26 09 : 09 : 12.622 Nav [8028 : f803] 행 : 0
내 실험실 elName.text 및 labelInfo.text는 사용자가 스크롤 할 때마다 변경됩니다.
그러나 영향을받는 셀은 맨 아래에만 있습니다. 9 번째 셀의 labelName을 [indexPath row]와 일관되게 유지하려면 어떻게해야합니까?
labelName.text 대신 cell.labelName.text를 설정해야합니까? – jrturton
U U tableview에 섹션이 있습니까? – tiguero
@jrturton - 그렇게 생각하지 마십시오. 모든 세포가 의도 한대로 작동하고 있습니다. 마지막 셀만 변경되는 것이 문제입니다. – Magnum