Skip to content

Commit 7186067

Browse files
committed
只有缓存的和准备使用类型一样才可以
1 parent 7df9d98 commit 7186067

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

ZHTableViewGroupExample/ZHTableViewGroupObjc/ZHTableViewDataSource.m

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,18 @@ + (UITableViewCell *)cellForRowAtWithDataSource:(ZHTableViewDataSource *)dataSou
7676
config:(BOOL)config
7777
useCache:(BOOL)useCache {
7878
ZHTableViewGroup *group = [self groupForSectionWithDataSource:dataSource section:indexPath.section];
79+
ZHTableViewCell *tableViewCell = [group tableViewCellForIndexPath:indexPath];
7980
UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];
8081
if (!group) {
8182
return cell;
8283
}
8384
UITableViewCell *resultCell;
8485
if (useCache) {
85-
resultCell = [dataSource cacheCellWithIndexPath:indexPath];
86-
ZHTableViewCell *tableViewCell = [group tableViewCellForIndexPath:indexPath];
87-
[group tableViewCell:tableViewCell configCell:resultCell atIndexPath:indexPath];
86+
UITableViewCell *cacheCell = [dataSource cacheCellWithIndexPath:indexPath];
87+
if ([cacheCell isKindOfClass:tableViewCell.anyClass]) {
88+
resultCell = [dataSource cacheCellWithIndexPath:indexPath];
89+
[group tableViewCell:tableViewCell configCell:resultCell atIndexPath:indexPath];
90+
}
8891
}
8992
if (!resultCell) {
9093
resultCell = [group cellForTableViewWithTableView:dataSource.tableView
@@ -94,7 +97,6 @@ + (UITableViewCell *)cellForRowAtWithDataSource:(ZHTableViewDataSource *)dataSou
9497
if (!resultCell) {
9598
return cell;
9699
}
97-
ZHTableViewCell *tableViewCell = [group tableViewCellForIndexPath:indexPath];
98100
NSIndexPath *realIndexPath = [group indexPathWithCell:tableViewCell indexPath:indexPath];
99101
BOOL isHidden = [tableViewCell isHiddenWithIndexPath:realIndexPath];
100102
resultCell.hidden = isHidden;

ZHTableViewGroupObjc.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'ZHTableViewGroupObjc'
11-
s.version = '3.5.3'
11+
s.version = '3.5.5'
1212
s.summary = 'Manger UITableView DataSource More Cell Style'
1313

1414
s.homepage = 'https://github.com/josercc/ZHTableViewGroup'

0 commit comments

Comments
 (0)