How to load section header dynamically like cells are loaded
I have a UITableView with a lot of rows and a lot of sections (over 500 sections). Having a lot of rows is not so bad, because only the visible rows are loaded using the dequeueReusableCellWithIdentifier method. The problem is that ALL of the section headers are loaded each time i perform [tableView reloadData].
Is there a way to use dequeued section headers the same way i use it for rows?
If not, the only two options i can think of is:
- handling the section header queue my self.
- Making the section headers to be custom cells and managing the sectio开发者_如何转开发n-cell mapping my self.
Both solutions are very complicated because i use NSFetchedResultsController.
If you are sure that all the section headers are loaded each time*, it means it's a system behavior.
What is complicated by using a NSFetchedResultsController ? If if really is, maybe you should write your own UITableViewDelegate/DataSource to have more flexibility.
*i.e. that
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
or
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
are called X times when you send the [tableView reloadData] message.
Fortunately for my acceptance rate - this issue was solved in iOS6 with: UITableView's dequeueReusableHeaderFooterViewWithIdentifier method.
精彩评论