UITableView tableHeaderView resizes after transition/reappear

Though that this might be a better place to post this than stack overflow:


I'm getting some odd behavior. I'm setting a tableHeaderView as follows:


    class MyTableViewController: UITableViewController {
        ...
        override func viewDidLoad() {
            ...
            var myHeaderView = NSBundle.mainBundle().loadNibNamed("MyHeaderView", owner: self, options: nil).first as? MyHeaderView
            tableView.tableHeaderView = myHeaderView
            ...
        }
        ...
    }


When the view loads up the first time, it displays correctly. Auto-layout gives it a height of `30`, and the table header height adheres to it.


When I segue to another view (via tapping a cell in the `UITableView`), then hit the back button, the `UITableView` draws with the correct height as well.


However, a split second after everything loads correctly the `tableViewHeader` resizes itself and covers a bit of the first cell. This is extremely frustrating because I can't seem to figure out where it's happening.


I added some log lines. Here's what it looks like after hitting the back button:


    viewWillAppear: header frame is Optional((0.0, 0.0, 375.0, 30.0))
    viewDidLayoutSubviews: header frame is Optional((0.0, 0.0, 375.0, 30.0))
    viewDidAppear: header frame is Optional((0.0, 0.0, 375.0, 30.0))
    viewDidLayoutSubviews: header frame is Optional((0.0, 0.0, 375.0, 49.0))
    viewDidLayoutSubviews: header frame is Optional((0.0, 0.0, 375.0, 49.0))


From what I can tell, something out of my control changes the height of the `tableViewHeader` between `viewDidAppear` and `viewDidLayoutSubviews`. I can't correct the size in `viewDidLayoutSubviews` because it triggers an infinite loop.


I'm at a loss as to what to do to fix this. Everything seems/behaves fine until the view reappears. It also breaks the correct height on transition to/from landscape.


Any help would be appreciated.

UITableView tableHeaderView resizes after transition/reappear
 
 
Q