dequan1331 / HybridPageKit

A high-performance、high-extensibility、easy integration framework for Hybrid content page. Support most content page types of News App.
MIT License
1.22k stars 184 forks source link

给TableView添加tableHeaderView和FooterView可能会导致计算出现问题 #42

Closed pcccccc closed 4 years ago

pcccccc commented 4 years ago

版本: 1.4.0 iOS版本: 13.4 复现:为您demo中的hotCommentView添加tableHeaderView 和FooterView 在HotCommentController.m中第57行插入

        UIView *headerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width , 5)];
        headerView.backgroundColor = UIColor.redColor;
        UIView *footerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0,  [UIScreen mainScreen].bounds.size.width , 5)];
        footerView.backgroundColor = UIColor.redColor;
        _hotCommentView.tableHeaderView = headerView;
        _hotCommentView.tableFooterView = footerView;
pcccccc commented 4 years ago

然后请问这是否是个bug还是设计问题本身不能支持Header Footer

dequan1331 commented 4 years ago

支持,是框架的bug。

用DEMO的实现方式,加上 tableView 的 header 会立即触发 contentSize 的变化,从而导致监听调用 relayout 引起循环的布局问题,已经修复 commit - 3cbd44f。

如果不更新框架的话,单纯修改业务实现逻辑也可以暂时规避,在HotCommentController 中,observeValueForKeyPath 函数中的 relayoutWithComponentChange dispatch到下一个runloop中执行即可。