dequan1331/HybridPageKit

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

pcccccc opened this issue · 2 comments

版本: 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;

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

支持,是框架的bug。

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

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