Contents

tableView(_:willSelectRowAt:)

Tells the delegate a row is about to be selected.

Declaration

optional func tableView(_ tableView: UITableView, willSelectRowAt indexPath: IndexPath) -> IndexPath?

Parameters

  • tableView:

    A table view informing the delegate about the impending selection.

  • indexPath:

    An index path locating the row in tableView.

Mentioned in

Return Value

An index path that confirms or alters the selected row. Return an IndexPath (Swift) or NSIndexPath (Objective-C) other than indexPath if you want another cell to be selected. Return nil if you don’t want the row selected.

Discussion

The system calls this method after a user has lifted their finger; the row is highlighted on the initial touch, but only selected when the touch withdraws. You can use UITableViewCell.SelectionStyle.none to disable the appearance of the cell highlight on the initial touch. The system doesn’t call this method if the rows in the table aren’t selectable. See Handling row selection in a table view for more information on controlling table row selection behavior.

See Also

Related Documentation

Responding to row selections