|
12 | 12 | @interface ZHTableViewDataSource () |
13 | 13 |
|
14 | 14 | @property (nonatomic, strong) NSMutableArray<ZHTableViewGroup *> *groups; |
15 | | -@property (nonatomic, strong) UITableView *tableView; |
| 15 | +@property (nonatomic, weak) UITableView *tableView; |
16 | 16 | @property (nonatomic, strong) ZHAutoConfigurationTableViewDelegate *autoConfiguration; |
17 | 17 |
|
18 | 18 | @end |
@@ -93,25 +93,51 @@ + (CGFloat)heightForRowAtDataSource:(ZHTableViewDataSource *)dataSource |
93 | 93 | return 0; |
94 | 94 | } |
95 | 95 |
|
96 | | - CGFloat automaticHeight = ({ |
97 | | - automaticHeight = CGFLOAT_MAX; |
98 | | - if (cell.height == NSNotFound) { |
99 | | - UITableViewCell *automaticHeightCell = [self cellForRowAtWithDataSource:dataSource indexPath:indexPath]; |
100 | | - NSIndexPath *realyIndexPath = [self indexPathWithDataSource:dataSource |
101 | | - indexPath:indexPath]; |
102 | | - [cell configCellWithCell:automaticHeightCell |
103 | | - indexPath:realyIndexPath]; |
104 | | - automaticHeight = [automaticHeightCell sizeThatFits:CGSizeMake([UIScreen mainScreen].bounds.size.width, CGFLOAT_MAX)].height; |
| 96 | + if (!dataSource.priorityHeight) { |
| 97 | + CGFloat automaticHeight = ({ |
| 98 | + automaticHeight = CGFLOAT_MAX; |
| 99 | + if (cell.height == NSNotFound) { |
| 100 | + UITableViewCell *automaticHeightCell = [self cellForRowAtWithDataSource:dataSource indexPath:indexPath]; |
| 101 | + NSIndexPath *realyIndexPath = [self indexPathWithDataSource:dataSource |
| 102 | + indexPath:indexPath]; |
| 103 | + [cell configCellWithCell:automaticHeightCell |
| 104 | + indexPath:realyIndexPath]; |
| 105 | + automaticHeight = [automaticHeightCell sizeThatFits:CGSizeMake([UIScreen mainScreen].bounds.size.width, CGFLOAT_MAX)].height; |
| 106 | + } |
| 107 | + automaticHeight; |
| 108 | + }); |
| 109 | + CGFloat height = cell.height; |
| 110 | + if (cell.height == NSNotFound && automaticHeight != CGFLOAT_MAX) { |
| 111 | + height = automaticHeight; |
105 | 112 | } |
106 | | - automaticHeight; |
107 | | - }); |
108 | | - CGFloat height = cell.height; |
109 | | - if (cell.height == NSNotFound && automaticHeight != CGFLOAT_MAX) { |
110 | | - height = automaticHeight; |
| 113 | + return [self heightWithCustomHandle:height |
| 114 | + customCompletionHandle:customHeightCompletionHandle |
| 115 | + baseModel:cell]; |
| 116 | + } else { |
| 117 | + CGFloat heigh = cell.height; |
| 118 | + if (heigh > 0 && heigh < CGFLOAT_MAX && heigh < NSNotFound) { |
| 119 | + return heigh; |
| 120 | + } |
| 121 | + if (customHeightCompletionHandle) { |
| 122 | + heigh = customHeightCompletionHandle(cell); |
| 123 | + if (heigh > 0 && heigh < CGFLOAT_MAX && heigh < NSNotFound) { |
| 124 | + return heigh; |
| 125 | + } |
| 126 | + } |
| 127 | + CGFloat automaticHeight = ({ |
| 128 | + automaticHeight = CGFLOAT_MAX; |
| 129 | + if (cell.height == NSNotFound) { |
| 130 | + UITableViewCell *automaticHeightCell = [self cellForRowAtWithDataSource:dataSource indexPath:indexPath]; |
| 131 | + NSIndexPath *realyIndexPath = [self indexPathWithDataSource:dataSource |
| 132 | + indexPath:indexPath]; |
| 133 | + [cell configCellWithCell:automaticHeightCell |
| 134 | + indexPath:realyIndexPath]; |
| 135 | + automaticHeight = [automaticHeightCell sizeThatFits:CGSizeMake([UIScreen mainScreen].bounds.size.width, CGFLOAT_MAX)].height; |
| 136 | + } |
| 137 | + automaticHeight; |
| 138 | + }); |
| 139 | + return automaticHeight; |
111 | 140 | } |
112 | | - return [self heightWithCustomHandle:height |
113 | | - customCompletionHandle:customHeightCompletionHandle |
114 | | - baseModel:cell]; |
115 | 141 | } |
116 | 142 |
|
117 | 143 | + (void)didSelectRowAtWithDataSource:(ZHTableViewDataSource *)dataSource |
|
0 commit comments