I'm loading a table view header from a xib file and setting it like this:
self.tableView.tableHeaderView = ... // My header view.
The view loaded from the xib is already the correct size (300 x 50px). When I execute this code in the table view controller's viewDidLoad method the header appears with a height of 0px. When I set it in the viewWillLayoutSubviews method, it appears with the correct height of 50px. In both cases the width is set to the correct width (634px).
I've seen lots of posts about setting the header height and I can get everything working fine by adding it in viewWillLayoutSubviews, but what I have not found is an explanation of why it works in viewWillLayoutSubviews and not viewDidLoad.
Does anyone know why?
As viewDidLoad is executed first, I would have thought adding the header there would be fine.