Iphone TDBadgedCell一直在缓存BadgeNumber
对于我正在进行的一个项目,我正在使用Tim Davies编写的TDBadgedCell。虽然单元在大多数情况下工作正常,但BadgeNumber会一直被缓存。我想知道我怎样才能解决这个问题 我的[tableView:CellForRowatineXpath]消息如下所示:Iphone TDBadgedCell一直在缓存BadgeNumber,iphone,objective-c,caching,uitableview,Iphone,Objective C,Caching,Uitableview,对于我正在进行的一个项目,我正在使用Tim Davies编写的TDBadgedCell。虽然单元在大多数情况下工作正常,但BadgeNumber会一直被缓存。我想知道我怎样才能解决这个问题 我的[tableView:CellForRowatineXpath]消息如下所示: - (UITableViewCell *)tableView:(UITableView *)_tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { sta
- (UITableViewCell *)tableView:(UITableView *)_tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
TDBadgedCell *cell = (TDBadgedCell *)[_tableView dequeueReusableCellWithIdentifier:CellIdentifier];
Contact *contact = [contactArray objectAtIndex:[indexPath row]];
if (cell == nil) {
cell = [[TDBadgedCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
}
[cell setBadgeNumber:[[contact unreadMessageCount] intValue]];
UIImage *statusImage = nil;
if ([[contact status] isEqualToString:@"online"]) {
statusImage = [[StatusController sharedInstance] imageForStatus:Online];
} else if ([[contact status] isEqualToString:@"away"]) {
statusImage = [[StatusController sharedInstance] imageForStatus:Away];
}
[[cell imageView] setImage:statusImage];
NSString *displayName = [contact displayName];
[[cell textLabel] setText:displayName];
NSString *phone = [contact phone];
[[cell detailTextLabel] setText:phone];
[cell setBadgeNumber:[[contact unreadMessageCount] intValue]];
return cell;
}
当我上下滚动时,文本和图像被正确重画。然而,徽章号码却没有。欢迎就如何解决这一问题提出任何建议 设置badgeNumber后,尝试调用单元格上的“setNeedsDisplay”以强制单元格重新绘制。实际上,尝试使用[cell.badge setNeedsDisplay]调用重新绘制;