Oh woe is me – iOS 5 has broken my app.
I have a UITableView and prior to iOS 5, the delegates where called in the sequence
- viewForHeaderInsection (which allowed me to dynamically create my
header view) - heightForHeaderInSection (which allowed me to
provide the adjusted height of the headerView
I’ve just checked now and run the program in the iOS 4.3 simulator and the iOS 5.0 simulator (and iOS 5 device) and the exact same code is invoked in the reverse sequence in iOS5 . WHY !!!!
The docs state (for tableView:heightForHeadInSection:)
“Special Considerations
Prior to iOS 5.0, table views would automatically resize the heights of headers to 0 for sections where tableView:viewForHeaderInSection: returned a nil view. In iOS 5.0 and later, you must return the actual height for each section header in this method.”
Nowhere does it state that they’ve quietly changed the sequence of calls.
My Question: Has anyone come across this, and any suggestions on resolving this? Do I recode everything ? I need to have a variable height header whose height I can only determine when I’ve created the headerView.
yes I observe the same behavior.
You create the header view in
tableView:heightForHeadInSectionand reuse it inviewForHeaderInsectioninstead of creating it twice.Prior to 5.0, you have to do a similar thing for
heightForRowAtIndexPathandcellForRowAtIndexPathif the height is known only after constructing the view.