在之前景图,當(dāng)tableView.style = UITableViewStyleGrouped的時(shí)候,設(shè)置sectionHeader和sectionFooter的高度為0的時(shí)候搪缨,往往設(shè)置0不管用<iOS10>食拜,會(huì)設(shè)置個(gè)0.01。為了封裝方便副编,可能有的時(shí)候當(dāng)tableView.style = UITableViewStylePlain的時(shí)候负甸,也會(huì)這么干。
這樣就會(huì)使得tableView.style = UITableViewStyleGrouped/UITableViewStylePlain的時(shí)候讓sectionHeader和sectionFooter的高度看不到了
但是在iOS14痹届,就會(huì)出現(xiàn)上面說(shuō)的那種情況,當(dāng)然了tableView.style = UITableViewStyleGrouped不受影響
適配方案:
1呻待、當(dāng)tableView.style = UITableViewStylePlain
iOS10~iOS14通用
都 return 0;
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 0;
}
2、如果當(dāng)前封裝的tableView兩種類型都有队腐,那么進(jìn)行相關(guān)的判斷
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
if (tableView.style == UITableViewStyleGrouped) {
return 0.01;
}
return 0;
}