我的解决方案是更新所有可见单元格并使用 reloadRowsAtIndexPaths 在我的自定义类“ProductTableViewCell”中跟踪单元格的 indexPath,见下文:
NSArray *arrayCells = [self.tableView visibleCells];
NSMutableArray *mArrayIndexPaths = [[NSMutableArray alloc] init];
for(ProductTableViewCell *cell in arrayCells) {
[mArrayIndexPaths addObject:cell.indexPath];
}
[self.tableView beginUpdates];
[self.tableView endUpdates];
[self.tableView reloadRowsAtIndexPaths:[mArrayIndexPaths copy] withRowAnimation:UITableViewRowAnimationAutomatic];
以下是类的定义方式:
@interface ProductTableViewCell : UITableViewCell {
NSString *reuseID;
}
@property (nonatomic, strong) NSIndexPath *indexPath;