Sunday, April 17, 2011

NSIndexPath - how to?

Hi, I want to implement index feature in UITableView as is in the standart contacts application.

Is there an elaborate tutorial how to achieve this goal? What is the right way to do so?

Data in my table is sorted alphabetically and when a user presses on a certain letter in the index I want to scroll to the same letter in the table.

How do I return number of rows in each section? Currently I have a function that calculates number of items in every section. Is there a way to calculate it automatically? When I get to a method cellForRowAtIndexPath I need to know an actual number of an item in the table, not the one in a row. How do I get it? i.e. I have 50 items in my table and 26 sections. When it comes to an item 30, I want to get 30, not "section:3 row:2". Is there a way to do so?

Thank you in advance.

From stackoverflow
  • As for the list on the side, use the UITableViewDataSource method sectionIndexTitlesForTableView:

    Keep in mind it only works if you're using UITableViewStylePlain

0 comments:

Post a Comment