开发者

How to load section header dynamically like cells are loaded

开发者 https://www.devze.com 2023-04-05 10:40 出处:网络
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 dequeueReusableCellWithIdentif

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:

  1. handling the section header queue my self.
  2. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消