Today we are going to the knowledge of is UITableView tableHeaderView, the junior partner to distinguish, not the header in the agreement, but overall the header, need to use the tableView. TableHeaderView to set. When using the tableView. TableHeaderView, if use undeserved, can cause the header to cover the cell, Cell content appears on the header or there is no system header between the header and the cell (even if the height and view are set to nil in the protocol). Note the following: 1. Do not use constraints. 2. Give the actual height value;

Blogger use relative height before layout, although constraints is also used, but not used here, recently used when suddenly discovered that with constraint headerView appeared problem, so I studied, found headerView must give out calculation in advance good height can be shown correctly, when using the constraint level constraints are not affected, Determine the height of the vertical direction and calculate it in advance. Otherwise, consider using the first cell to implement headerView.

// The header is not affected by the constraint. You don't have to set a fixed height and it doesn't matter - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)sectionCopy the code