我解決方案是更新所有可見單元格並使用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;