I’m playing with storyboards and for one controller I set up a UITableView that consists of two sections. In both sections I have added a couple of static cells.
However, depending on code paths, I would like to show different headers for my two sections.
As there is no source and no delegate involved, how am I supposed to override tableView:titleForHeaderInSection: ?
I’m playing with storyboards and for one controller I set up a UITableView that
Share
With static table views you can (and must) still connect the datasource to a UITableViewController. The key is that if you implement the datasource methods then this will override the static content you have set up in the table view. You can override titleForHeader without any problems since this is what you want to do.
Sets the title of section 0 in the static table to HELLO!, overriding the title set in the xib. The others are left as the were in the xib.
The key point is that static tables are populated exactly the same way as dynamic tables, except that UITableViewController implements its own versions of all the datasource methods. These methods presumably read the information from the xib file and send back the appropriate information to the table view. If you want the static content, don’t implement or call super. If you want your own content, use code similar to that above.