項目開發(fā)中看到了tableView的方法如下:
- (nullable UITableViewHeaderFooterView *)headerViewForSection:(NSInteger)section
照字面意思理解,是創(chuàng)建tableView的sectionHeaderView,但是實(shí)際使用中卻不會調(diào)用.
遍查文檔,才明白原來上述方法并不屬于UITableViewDelegate的方法,只是tableView的內(nèi)部方法,所以才無法被調(diào)用.
如果遇到要使用sectionHeaderView的方法,應(yīng)該使用如下方法:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section//生成UITableViewHeaderFooterView
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section//控制高度
下面是在StackOverFlow搜到的答案:
(headerViewForSection無法調(diào)用)
喜歡和收藏都是對我的鼓勵和支持~