Skip to content

Commit

Permalink
helper添加设置所有model均需重新计算接口
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeWicky committed Oct 17, 2018
1 parent 0e660e9 commit 6ca187d
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 3 deletions.
6 changes: 5 additions & 1 deletion DWTableViewHelper/DWTableViewHelper.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
version 1.1.7.1
model添加重新自动计算高度接口
helper添加设置所有model均需重新计算接口
*/

#import <UIKit/UIKit.h>
Expand Down Expand Up @@ -401,14 +402,17 @@ typedef NS_ENUM(NSUInteger, DWTableViewHelperLoadDataMode) {///数据加载优
///修复iOS11后refreshControl位置错误
-(void)fixRefreshControlInsets;


/**
设置自动放大的头视图,与tableHeaderView相互冲突
@param header 设置的headerView
@param handler 当滚动时的触发回调,可在此处处理导航透明度
*/
-(void)setAutoZoomHeader:(UIView *)header scrollHandler:(void(^)(CGFloat contentoffset))handler;

///设置当前所有模型均为需要重新自动计算高度
-(void)setAllNeedsReAutoCalculateRowHeight;

@end

#pragma mark --- DWTableViewHelperModel 数据模型基类 ---
Expand Down
19 changes: 17 additions & 2 deletions DWTableViewHelper/DWTableViewHelper.m
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,22 @@ -(void)removeAutoZoomHeader {
}
}

-(void)setAllNeedsReAutoCalculateRowHeight {
[self.dataSource enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
[self setObjNeedsReAutoCalculateRowHeight:obj];
}];
}

-(void)setObjNeedsReAutoCalculateRowHeight:(id)anObj {
if ([anObj isKindOfClass:[NSArray class]]) {
[((NSArray *)anObj) enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
[self setObjNeedsReAutoCalculateRowHeight:obj];
}];
} else if ([anObj isKindOfClass:[DWTableViewHelperModel class]]) {
[((__kindof DWTableViewHelperModel *)anObj) setNeedsReAutoCalculateRowHeight];
}
}

#pragma mark --- delegate Map Start ---
///display
-(void)tableView:(UITableView *)tableView willDisplayCell:(DWTableViewHelperCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath
Expand Down Expand Up @@ -1504,8 +1520,7 @@ @implementation DWTableViewHelperModel
@synthesize cellClassStr,cellID,cellRowHeight,cellEditSelectedIcon,cellEditUnselectedIcon;

-(instancetype)init{
self = [super init];
if (self) {
if (self = [super init]) {
self.cellRowHeight = -1;
if (!ImageNull) {
ImageNull = [UIImage new];
Expand Down

0 comments on commit 6ca187d

Please sign in to comment.