Вопрос

I have an indexed table view in which the cells are grouped alphabetically into sections. I would like to be able to only load a block of the data associated with a particular section when that indexed section is selected. In other words, my table view is the type where there is a selectable field at the right side of the table view that contains the letters A-Z. You can select the letter P for example to jump to cells that have content that starts with the letter P.

Is there any way to detect the selection of an indexed section so that I can then reload the cells in that section once I load the block of data associated with that section?

Это было полезно?

Решение

As the user uses the index down the side, the UITableViewDataSource tableView:sectionForSectionIndexTitle:atIndex: method will be called.

You can add logic to this method that if this is the first time you've seen a given section index, that you need to load the data for the section.

But keep in mind that long before this you would have already told the table how many total sections there are and how many rows are in each of those sections. So long before your table even shows the index down the side, you need to have at least loaded counts for all of the sections but not necessarily the detailed data.

Also keep in mind that a user can slide their finger down the index list. This means the table will want to jump to each and every section as the user slides their finger. So whatever lazy loading you do needs to deal with this in a nice manner (not making the UI sluggish).

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top