Sections and Indexing Tables

If you look at Phoneapp or Contactsapp, you’ll notice that the alphabetical listing of your contacts has sticky headers at the top of the screen that indicate which part of the list you’re viewing. These are the default UITableView section dividers. You’ll also notice a bar on the right side that acts as a quick index for these sections, which is another built-in element of sections in UITableView. We’re going to learn about both and add them to our app.

Adding sections to a table is pretty easy: implement a few more methods and add some additional logic in the existing dataSource implementations. Ideally, your data should be structured as a hash where the keys are your section titles and the values are rows contained ...

Get RubyMotion now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.