Skip to content

Commit 63b54bd

Browse files
author
15038777234
committed
201707251012
Fix: 修复无法关闭自动代理 Add: 新增配置HeaderFooterView
1 parent 53d571c commit 63b54bd

7 files changed

Lines changed: 19 additions & 11 deletions

File tree

.DS_Store

0 Bytes
Binary file not shown.

Example/ZHTableViewGroup/ZHViewController.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,10 @@ - (void)registerTwoCellWithCell:(ZHTableViewCell *)cell {
9696
[cell setConfigCompletionHandle:^(UITableViewCell *cell, NSIndexPath *indexPath) {
9797
cell.textLabel.text = @"Your Background";
9898
}];
99+
cell.customHeightCompletionHandle = ^CGFloat(UITableView *tableView, NSIndexPath *indexPath, ZHTableViewBaseModel *model) {
100+
/// 可以使用一些第三方库或者自己的方法计算高度
101+
return 0;
102+
};
99103

100104
}
101105

ZHTableViewGroup/.DS_Store

2 KB
Binary file not shown.

ZHTableViewGroup/Classes/ZHTableViewDataSource.m

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,11 @@ @implementation ZHTableViewDataSource
2222
- (instancetype)initWithTableView:(UITableView *)tableView {
2323
if (self = [super init]) {
2424
_tableView = tableView;
25-
self.autoConfigurationTableViewDelegate = YES;
25+
_autoConfigurationTableViewDelegate = YES;
2626
}
2727
return self;
2828
}
2929

30-
- (void)setAutoConfigurationTableViewDelegate:(BOOL)autoConfigurationTableViewDelegate {
31-
_autoConfigurationTableViewDelegate = autoConfigurationTableViewDelegate;
32-
if (autoConfigurationTableViewDelegate) {
33-
_tableView.dataSource = self.autoConfiguration;
34-
_tableView.delegate = self.autoConfiguration;
35-
}
36-
}
37-
3830
- (void)addGroupWithCompletionHandle:(ZHTableViewDataSourceAddGroupCompletionHandle)completionHandle {
3931
ZHTableViewGroup *group = [[ZHTableViewGroup alloc] init];
4032
if (completionHandle) {
@@ -44,6 +36,10 @@ - (void)addGroupWithCompletionHandle:(ZHTableViewDataSourceAddGroupCompletionHan
4436
}
4537

4638
- (void)reloadTableViewData {
39+
if (self.isAutoConfigurationTableViewDelegate) {
40+
self.tableView.dataSource = self.autoConfiguration;
41+
self.tableView.delegate = self.autoConfiguration;
42+
}
4743
[self registerClasss];
4844
[self.tableView reloadData];
4945
}

ZHTableViewGroup/Classes/ZHTableViewGroup.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,11 @@ - (UITableViewHeaderFooterView *)headerFooterForStyle:(ZHTableViewHeaderFooterSt
107107
if (!headerFooter.identifier) {
108108
return nil;
109109
}
110-
return [tableView dequeueReusableHeaderFooterViewWithIdentifier:headerFooter.identifier];
110+
UITableViewHeaderFooterView *headerFooterView = [tableView dequeueReusableHeaderFooterViewWithIdentifier:headerFooter.identifier];
111+
if (headerFooter.configurationHeaderFooterViewCompletionHandle) {
112+
headerFooter.configurationHeaderFooterViewCompletionHandle(headerFooterView);
113+
}
114+
return headerFooterView;
111115
}
112116

113117

ZHTableViewGroup/Classes/ZHTableViewHeaderFooter.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ typedef NS_ENUM(NSUInteger, ZHTableViewHeaderFooterStyle) {
1616
@interface ZHTableViewHeaderFooter : ZHTableViewBaseModel
1717

1818
@property (nonatomic, assign) ZHTableViewHeaderFooterStyle style;
19+
/**
20+
* 配置头部和尾部
21+
*/
22+
@property (nonatomic, copy) void(^configurationHeaderFooterViewCompletionHandle)(UITableViewHeaderFooterView *headerFooterView);
1923

2024
- (instancetype)initWithStyle:(ZHTableViewHeaderFooterStyle)style;
2125

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 = '2.5.1'
11+
s.version = '2.5.2'
1212
s.summary = 'Manger UITableView DataSource More Cell Style'
1313

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

0 commit comments

Comments
 (0)