Table View Scrolling and Layout

A UITableView is a UIScrollView, so everything you already know about scroll views is applicable (Chapter 20). In addition, a table view supplies two convenience scrolling methods:

  • scrollToRowAtIndexPath:atScrollPosition:animated:
  • scrollToNearestSelectedRowAtScrollPosition:animated:

The scrollPosition parameter is as for selectRowAtIndexPath:..., discussed earlier in this chapter.

The following UITableView methods mediate between the table’s bounds coordinates on the one hand and table structure on the other:

  • indexPathForRowAtPoint:
  • indexPathsForRowsInRect:
  • rectForSection:
  • rectForRowAtIndexPath:
  • rectForFooterInSection:
  • rectForHeaderInSection:

The table’s header and footer are views, so their coordinates are given by their frames.

Get Programming iOS 6, 3rd Edition 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.