这篇文章缓存问题密切相关,我以前的帖子:TDBadgedCell keeps caching the BadgeNumber与TDBadgedCell
的“徽章”从TDBadgedCell保持高速缓存的数量。一个非常简单的例子如下:
- (UITableViewCell *)tableView:(UITableView *)_tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
TDBadgedCell *cell = (TDBadgedCell *)[_tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[TDBadgedCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
}
[cell setBadgeColor:[UIColor blackColor]];
[cell setBadgeNumber:[indexPath row]];
[[cell textLabel] setText:[NSString stringWithFormat:%@"%d", [indexPath row]]];
return cell;
}
任何人都有任何线索为什么会发生这种情况? textLabel和detailTextLabel不会缓存数据。任何额外的信息也会受到欢迎,因为我似乎在UITableViewCells中缓存图形有很多问题。任何最佳实践或其他有用的信息将是最受欢迎的。