diff --git a/DWTableViewHelper/DWTableViewHelper.h b/DWTableViewHelper/DWTableViewHelper.h index 999520b..ecb39cd 100755 --- a/DWTableViewHelper/DWTableViewHelper.h +++ b/DWTableViewHelper/DWTableViewHelper.h @@ -477,6 +477,22 @@ typedef NS_ENUM(NSUInteger, DWTableViewHelperLoadDataMode) {///数据加载优 ///配合DWTableViewHelperLoadDataIgnoreHighSpeedMode使用,标志cell是否被绘制过 @property (nonatomic ,assign ,readonly) BOOL cellHasBeenDrawn; +/** + 当前正在展示的cell + + 在willDisplayCell之后被赋值为对应的cell,在didEndDisplaying之后被置空 + */ +@property (nonatomic ,weak ,readonly) __kindof DWTableViewHelperCell * currentDisplayCell; + +/** + 当前正在展示的cell对应的indexPath + + 在willDisplayCell之后被赋值为对应的cell的indexPath,在didEndDisplaying之后被置空 + */ +@property (nonatomic ,strong ,readonly) NSIndexPath * currentDisplayIndexPath; + + + ///设置需要重新自动计算高度 -(void)setNeedsReAutoCalculateRowHeight; diff --git a/DWTableViewHelper/DWTableViewHelper.m b/DWTableViewHelper/DWTableViewHelper.m index bc764f0..63a4ac2 100644 --- a/DWTableViewHelper/DWTableViewHelper.m +++ b/DWTableViewHelper/DWTableViewHelper.m @@ -54,6 +54,10 @@ @interface DWTableViewHelperModel () @property (nonatomic ,strong) UIImage * cellSnap; +@property (nonatomic ,weak) __kindof DWTableViewHelperCell * currentDisplayCell; + +@property (nonatomic ,strong) NSIndexPath * currentDisplayIndexPath; + @end @implementation DWTableViewHelper @@ -375,6 +379,9 @@ -(void)tableView:(UITableView *)tableView willDisplayCell:(DWTableViewHelperCell return; } + cell.model.currentDisplayCell = cell; + cell.model.currentDisplayIndexPath = indexPath; + if (self.cellEditSelectedIcon && cell.model.cellEditSelectedIcon == ImageNull) { cell.model.cellEditSelectedIcon = self.cellEditSelectedIcon; } @@ -409,10 +416,12 @@ - (void)tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)view } } -- (void)tableView:(UITableView *)tableView didEndDisplayingCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath*)indexPath { +- (void)tableView:(UITableView *)tableView didEndDisplayingCell:(DWTableViewHelperCell *)cell forRowAtIndexPath:(NSIndexPath*)indexPath { if (DWDelegate && [DWDelegate respondsToSelector:@selector(dw_tableView:didEndDisplayingCell:forRowAtIndexPath:)]) { [DWDelegate dw_tableView:tableView didEndDisplayingCell:cell forRowAtIndexPath:indexPath]; } + cell.model.currentDisplayCell = nil; + cell.model.currentDisplayIndexPath = nil; } - (void)tableView:(UITableView *)tableView didEndDisplayingHeaderView:(UIView *)view forSection:(NSInteger)section { @@ -826,10 +835,10 @@ -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NS return placeHolderCell(); } DWTableViewHelperCell * cell = nil; - DWTableViewHelperModel * model = [self modelFromIndexPath:indexPath]; if (DWDelegate && [DWDelegate respondsToSelector:@selector(dw_tableView:cellForRowAtIndexPath:)]) { cell = [DWDelegate dw_tableView:tableView cellForRowAtIndexPath:indexPath]; } + DWTableViewHelperModel * model = [self modelFromIndexPath:indexPath]; if (!cell) { cell = [self createCellFromModel:model useReuse:YES];