iOS UITableView heightForHeaderInSection不調用

UITableView設置爲Group樣式。

不走heightForHeaderInSection/heightForFooterInSection方法。

1,對於沒隱藏蘋果原生的navigationBar的

iOS11默認開啓Self-Sizing,關閉Self-Sizing即可。

self.tableView.estimatedRowHeight = 0; 
self.tableView.estimatedSectionHeaderHeight = 0;
self.tableView.estimatedSectionFooterHeight = 0;

2,對於隱藏了蘋果原生navigationBar,用UIView自己寫navigationBar的

可能是沒有實現tableView: viewForHeaderInSection:/tableView: viewForFooterInSection:造成的。

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 10;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    return [[UIView alloc] init];
} 

//viewForFooterInSection同理

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章