Changing UITableView section header without tableView:titleForHeaderInSection
Calling [tableView endUpdates]
may provide the desired results without too much of a performance hit.
[self.tableView beginUpdates];
[self.tableView endUpdates];
// forces the tableView to ask its delegate/datasource the following:
// numberOfSectionsInTableView:
// tableView:titleForHeaderInSection:
// tableView:titleForFooterInSection:
// tableView:viewForHeaderInSection:
// tableView:viewForFooterInSection:
// tableView:heightForHeaderInSection:
// tableView:heightForFooterInSection:
// tableView:numberOfRowsInSection:
with:
[self.tableView headerViewForSection:i]
you could get the view for Section i and then "update" it manually
this even works if your view is just the auto-generated label, but you will have to resize it yourself. so if you try to:
[self.tableView headerViewForSection:i].textLabel.text = [self tableView:self.tableView titleForHeaderInSection:i];
you will set the text, but you would not set the label-size. You can get the needed size from NSString to set it yourself:
[label.text sizeWithFont:label.font];
There doesn't appear to be any standard API for accessing the system-provided section header view. Have you tried the more targeted reloadSections:withRowAnimation
to get UIKit to display the new header text?
What kind of performance issues were you seeing with custom section header views? I doubt that the standard one is much more than just a UILabel
.