Skip to content

Commit

Permalink
新增 -willDisplayHeaderView 和 -didEndDisplayingHeaderView回调
Browse files Browse the repository at this point in the history
  • Loading branch information
SmileZXLee committed Nov 4, 2020
1 parent fa6cb1c commit f0c3e64
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ZXTableView.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'ZXTableView'
s.version = '1.1.0'
s.version = '1.1.1'
s.summary = '快速构建TableView'
s.homepage = 'https://github.com/SmileZXLee/ZXTableView'
s.license = 'MIT'
Expand Down
4 changes: 4 additions & 0 deletions ZXTableView/ZXTableView.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, copy) NSArray<UITableViewRowAction *>* (^zx_editActionsForRowAtIndexPath)(NSIndexPath *indexPath);
///cell将要展示,把id改成对应类名即可无需强制转换
@property (nonatomic, copy) void (^zx_willDisplayCell)(NSIndexPath *indexPath,id cell);
///headerView将要展示,把id改成对应类名即可无需强制转换
@property (nonatomic, copy) void (^zx_willDisplayHeaderView)(NSInteger section,id headerView);
///headerView已经展示完毕,把id改成对应类名即可无需强制转换
@property (nonatomic, copy) void (^zx_didEndDisplayingHeaderView)(NSInteger section,id headerView);
///scrollView滚动事件
@property (nonatomic, copy) void (^zx_scrollViewDidScroll)(UIScrollView *scrollView);
///scrollView缩放事件
Expand Down
23 changes: 22 additions & 1 deletion ZXTableView/ZXTableView.m
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,12 @@ -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPat
}
#pragma mark tableView cell 将要展示
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
!self.zx_willDisplayCell ? : self.zx_willDisplayCell(indexPath,cell);
if([self.zxDelegate respondsToSelector:@selector(tableView:willDisplayCell:forRowAtIndexPath:)]){
[self.zxDelegate tableView:tableView willDisplayCell:cell forRowAtIndexPath:indexPath];
}else{
!self.zx_willDisplayCell ? : self.zx_willDisplayCell(indexPath,cell);
}

}
#pragma mark tableView HeaderView & FooterView
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
Expand Down Expand Up @@ -313,6 +318,22 @@ -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger
}
}

-(void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section{
if([self.zxDelegate respondsToSelector:@selector(tableView:willDisplayHeaderView:forSection:)]){
[self.zxDelegate tableView:tableView willDisplayHeaderView:view forSection:section];
}else{
!self.zx_willDisplayHeaderView ? : self.zx_willDisplayHeaderView(section,view);
}
}

- (void)tableView:(UITableView *)tableView didEndDisplayingHeaderView:(UIView *)view forSection:(NSInteger)section{
if([self.zxDelegate respondsToSelector:@selector(tableView:willDisplayHeaderView:forSection:)]){
[self.zxDelegate tableView:tableView didEndDisplayingHeaderView:view forSection:section];
}else{
!self.zx_didEndDisplayingHeaderView ? : self.zx_didEndDisplayingHeaderView(section,view);
}
}

#pragma mark - scrollView相关代理
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
if([self.zxDelegate respondsToSelector:@selector(scrollViewDidScroll:)]){
Expand Down
4 changes: 4 additions & 0 deletions ZXTableViewDemo/ZXTableViewDemo/ZXTableView/ZXTableView.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,10 @@ NS_ASSUME_NONNULL_BEGIN
@property (nonatomic, copy) NSArray<UITableViewRowAction *>* (^zx_editActionsForRowAtIndexPath)(NSIndexPath *indexPath);
///cell将要展示,把id改成对应类名即可无需强制转换
@property (nonatomic, copy) void (^zx_willDisplayCell)(NSIndexPath *indexPath,id cell);
///headerView将要展示,把id改成对应类名即可无需强制转换
@property (nonatomic, copy) void (^zx_willDisplayHeaderView)(NSInteger section,id headerView);
///headerView已经展示完毕,把id改成对应类名即可无需强制转换
@property (nonatomic, copy) void (^zx_didEndDisplayingHeaderView)(NSInteger section,id headerView);
///scrollView滚动事件
@property (nonatomic, copy) void (^zx_scrollViewDidScroll)(UIScrollView *scrollView);
///scrollView缩放事件
Expand Down
23 changes: 22 additions & 1 deletion ZXTableViewDemo/ZXTableViewDemo/ZXTableView/ZXTableView.m
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,12 @@ -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPat
}
#pragma mark tableView cell 将要展示
-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{
!self.zx_willDisplayCell ? : self.zx_willDisplayCell(indexPath,cell);
if([self.zxDelegate respondsToSelector:@selector(tableView:willDisplayCell:forRowAtIndexPath:)]){
[self.zxDelegate tableView:tableView willDisplayCell:cell forRowAtIndexPath:indexPath];
}else{
!self.zx_willDisplayCell ? : self.zx_willDisplayCell(indexPath,cell);
}

}
#pragma mark tableView HeaderView & FooterView
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
Expand Down Expand Up @@ -313,6 +318,22 @@ -(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger
}
}

-(void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section{
if([self.zxDelegate respondsToSelector:@selector(tableView:willDisplayHeaderView:forSection:)]){
[self.zxDelegate tableView:tableView willDisplayHeaderView:view forSection:section];
}else{
!self.zx_willDisplayHeaderView ? : self.zx_willDisplayHeaderView(section,view);
}
}

- (void)tableView:(UITableView *)tableView didEndDisplayingHeaderView:(UIView *)view forSection:(NSInteger)section{
if([self.zxDelegate respondsToSelector:@selector(tableView:willDisplayHeaderView:forSection:)]){
[self.zxDelegate tableView:tableView didEndDisplayingHeaderView:view forSection:section];
}else{
!self.zx_didEndDisplayingHeaderView ? : self.zx_didEndDisplayingHeaderView(section,view);
}
}

#pragma mark - scrollView相关代理
-(void)scrollViewDidScroll:(UIScrollView *)scrollView{
if([self.zxDelegate respondsToSelector:@selector(scrollViewDidScroll:)]){
Expand Down

0 comments on commit f0c3e64

Please sign in to comment.