在iOS11之前,設(shè)置Tableview的section的頭部高度只需要實(shí)現(xiàn)代理heightForHeaderInSection就可以,但是到了iOS11之后,只實(shí)現(xiàn)這個(gè)方法是不行的同時(shí)需要實(shí)現(xiàn)代理方法viewForHeaderInSection,實(shí)現(xiàn)如下:
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
return 50;
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 5;
}
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
return nil;
}
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
return nil;
}
如果需要自定義組的頭部試圖就可以在viewForHeaderInSection創(chuàng)建自定義試圖就可以了