UITableView在 UITableViewStyleGrouped樣式下第一組組頭莫名變高,針對這個問題有以下兩種方式處理
1、直接設置contentInset,不推薦這個方法,雖然能夠解決問題
self.homeTableView.contentInset = UIEdgeInsetsMake(-36, 0, 0, 0);
2、通過UITableViewDelegate代理方法實現,不要試圖設置為0,會不起作用
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section { return nil; } - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { return 0.001; }