를 귀하의 경우에는 방금 보이는 모든 세포에 대한 포인터를 얻을하고 업데이트 할 수 있습니다하는 내용으로합니다. 이런 식으로 뭔가 :
- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath
{
NSArray* visibleCells = [tableView indexPathsForVisibleRows];
for (NSIndexPath* indexPath in visibleCells)
{
UITableViewCell* cell = [self.tableView cellForRowAtIndexPath:indexPath];
[self updateCell:cell atIndexPath:indexPath]; // Your method, which updates content...
}
}
그리고 콘텐츠 다른 세포를 업데이트 할 경우이 같은 것을 사용할 수 있습니다
- (void)tableView:(UITableView*)tableView willDisplayCell:(UITableViewCell*)cell forRowAtIndexPath:(NSIndexPath*)indexPath
{
[self updateCell:cell atIndexPath:indexPath]; // Your method, which updates content...
}
그래서 당신의 세포가 항상 정확한 내용을 표시합니다.
만드는 내용 정보
:
- (UITableViewCell*)tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString* CellIdentifier = @"Cell";
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
[self createContentForCell:cell atIndexPath:indexPath]; // so here to create content or customize cell
}
return cell;
}
좋아요, 감사 남자! 그러나 이것은 셀 내용 작성 코드를'cellForRowAtIndexPath'에서 멀리 옮기는 것을 의미합니다. 그러나 이것은 어쨌든 좋은 일입니다. –
도움이된다면 기꺼이 도와 드리겠습니다. –
일반적으로 성능 셀의 내용은 cellForRowAtIndexPath 메소드에서 작성됩니다 if (cell == nil) {... // 여기; }. 그리고 willDisplayCell 메서드는 무언가를 업데이트 할 수 있습니다 (예 : 일부 활동 표시기 중지). –