UITableView shouldn't ask for section header view after every scroll movement

Number:rdar://6965792 Date Originated:11-Jun-2009 06:19 PM
Status:Open Resolved:
Product:iPhone SDK Product Version:3.0
Classification:Performance Reproducible:Always
UITableView calls is delegate method -tableView:viewForHeaderInSection: every time it scrolls (on every single change of contentOffset). This results in a sizable performance hit, especially in the case where the developer is not aware of this fact (as I'm guessing is the predominant case) and does not cache the UIView being returned for use as the header and instead allocates and sets up a new UIView on every message.

Steps to Reproduce:
1. Implement -tableView:viewForHeaderInSection: for a UITableViewController subclass.
2. Create and set up a UIView to be used for the header.
3. NSLog each call to -tableView:viewForHeaderInSection:, and return the created header view.
4. Run and Debug, pull up the debugging console, and drag on the table view to scroll.

Expected Results:
A new message is logged only when a new section scrolls into the visible area. In other words, the table view's delegate is only asked for a section header view as needed, and no more.

Actual Results:
Watch as the debugging console fills (and probably lags behind) with a tide of logging messages, since the -tableView:viewForHeaderInSection: method is called on every minute change to contentOffset.


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!