How can I get the UITableView scroll position so I can save it?

progrmr picture progrmr · May 9, 2010 · Viewed 73.1k times · Source

Is there any way to find out which UITableViewCell is at the top of the scroll window?

I'd like to get the current scroll position so that I can save it when the app exits. When the app gets started I want to scroll to the position it was at when it last exited.

Answer

Ben Gottlieb picture Ben Gottlieb · May 9, 2010

You can easily grab the exact offset of the table view by looking at its contentOffset property. For the vertical scroll, look at:

tableView.contentOffset.y;