How do I, from a cell, get its indexPath
in a UITableView
?
I\'ve searched around stack overflow and google, but all the information is on t
On iOS 11.0, you can use UITableView.indexPathForRow(at point: CGPoint) -> IndexPath?
:
if let indexPath = tableView.indexPathForRow(at: cell.center) {
tableView.selectRow
(at: indexPath, animated: true, scrollPosition: .middle)
}
It gets the center point of the cell and then the tableView returns the indexPath corresponding to that point.