UITableView always loads all section titles
| Originator: | wangjammer5 | ||
| Number: | rdar://14829662 | Date Originated: | 25-Aug-2013 03:15 PM |
| Status: | Open | Resolved: | |
| Product: | iOS SDK | Product Version: | 7 beta 11A4449d |
| Classification: | Performance | Reproducible: | Always |
Summary: I noticed that in my app the UITableView when it initialises requests info about all of the sections in the data source, even if they will not yet be displayed. This can cause a huge amount of unnecessary data lookups. What's more, the problems seems to be an unintended side effect of updating the section count on the UITableView. Steps to Reproduce: 1) Create an app with UITableView 2) Add a table view delegate 3) Implement - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section 4) Add a breakpoint in the implementation of tableView:titleForHeaderInSection 5) Implement - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView to return a non-zero number, say 25 6) Run the app and see tableView:titleForHeaderInSection called 25 times as the view is about to be presented Expected Results: tableView:titleForHeaderInSection should only be called for the sections that will be visible on the initial screen. Actual Results: tableView:titleForHeaderInSection is called once for every section declared in numberOfSectionsInTableView, causing potentially huge amounts of unnecessary data retrieval. Regression: Not sure. Notes: I'm attaching a screen grab of the call stack showing what causes the tableView:titleForHeaderInSection to be called in this scenario. It looks like a side effect of [UITableViewRowData numberOfRows.]
Comments
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!