Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Scroll UITableView to display selected cell

Tags:

ios

If I have a UITableView with a selected cell, how can I scroll the table so the selected cell is visible? (Or better, so that cell is in the middle of the screen).

Thanks!

like image 605
Ferran Maylinch Avatar asked Sep 11 '25 20:09

Ferran Maylinch


1 Answers

if let indexPath = tableView.indexPathForSelectedRow {
    tableView.scrollToRowIndexPath(indexPath, atScrollPosition: .None, animated: true)
}
like image 80
keithbhunter Avatar answered Sep 13 '25 10:09

keithbhunter