Avoid a UITableView headache
When using a custom section header view on a grouped
UITableView, remember to implement the
heightForHeaderInSection delegate method.
I initially left this out of a recent project because the documentation for the UITableView delegate method viewForHeaderInSection states:
The table view automatically adjusts the height of the section header to accommodate the returned view object.
What actually happened is that my header view was being clipped at the top and bottom, even though it was a
UILabel which was the same font, weight and size of a standard section header (for the curious: I was attempting to change the text color).
A quick perusal of the documentation revealed the existence of a
heightForHeaderInSection delegate method which made the view display as expected and there was much rejoicing.
Comments are closed for this post.