Delegate Methods in TableView Using Swift-(Part 2)

Sahil Pathania
3 min readJun 13, 2021
Delegate Methods in TableView Using Swift

Hi Everyone! This blog will let you know about the delegate methods in the table view. If you don’t know much about table view and want to know more about it then you can check my other blog “How to Start with TableView in Swift”.

There are many Delegates methods in swift. So, I divided it into two blogs half of the methods will cover in this blog, and the rest will be covered in my last blog.

didHighlightRowAt
func tableView(_ tableView: UITableView, didHighlightRowAt indexPath: IndexPath)

Tells the delegate that the specified row was highlighted.

didUnhighlightRowAt
func tableView(_ tableView: UITableView, didUnhighlightRowAt indexPath: IndexPath)

Tells the delegate that the highlight was removed from the row at the specified index path.

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

Tells the delegate a row is about to be selected.

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

Tells the delegate that a specified row is about to be deselected.

didSelectRowAt
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)

Tells the delegate a row is selected.

didDeselectRowAt
func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath)

Tells the delegate that the specified row is now deselected.

editingStyleForRowAt
func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCell.EditingStyle

Asks the delegate for the editing style of a row at a particular location in a table view.

titleForDeleteConfirmationButtonForRowAt
func tableView(_ tableView: UITableView, titleForDeleteConfirmationButtonForRowAt indexPath: IndexPath) -> String?

Changes the default title of the delete-confirmation button.

editActionsForRowAt
func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]?

Asks the delegate for the actions to display in response to a swipe in the specified row.

leadingSwipeActionsConfigurationForRowAt
func tableView(_ tableView: UITableView, leadingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration?

Returns the swipe actions to display on the leading edge of the row.

trailingSwipeActionsConfigurationForRowAt
func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration?

Returns the swipe actions to display on the trailing edge of the row.

shouldIndentWhileEditingRowAt
func tableView(_ tableView: UITableView, shouldIndentWhileEditingRowAt indexPath: IndexPath) -> Bool

Asks the delegate whether the background of the specified row should be indented while the table view is in editing mode.

willBeginEditingRowAt
func tableView(_ tableView: UITableView, willBeginEditingRowAt indexPath: IndexPath)

Tells the delegate that the table view is about to go into editing mode.

didEndEditingRowAt
func tableView(_ tableView: UITableView, didEndEditingRowAt indexPath: IndexPath?)

Tells the delegate that the table view has left editing mode.

targetIndexPathForMoveFromRowAt
func tableView(_ tableView: UITableView, targetIndexPathForMoveFromRowAt sourceIndexPath: IndexPath, toProposedIndexPath proposedDestinationIndexPath: IndexPath) -> IndexPath

Asks the delegate to return a new index path to retarget a proposed move of a row.

shouldBeginMultipleSelectionInteractionAt
func tableView(_ tableView: UITableView, shouldBeginMultipleSelectionInteractionAt indexPath: IndexPath) -> Bool

Asks the delegate whether the user can use a two-finger pan gesture to select multiple items in a table view.

didBeginMultipleSelectionInteractionAt
func tableView(_ tableView: UITableView, didBeginMultipleSelectionInteractionAt indexPath: IndexPath)

Tells the delegate when the user starts using a two-finger pan gesture to select multiple rows in a table view.

tableViewDidEndMultipleSelectionInteraction
func tableViewDidEndMultipleSelectionInteraction(_ tableView: UITableView)

Tells the delegate when the user stops using a two-finger pan gesture to select multiple rows in a table view.

Thankyou

--

--

Sahil Pathania

iOS Application Developer | “Nothing is more beautiful than a beautifully written <code/>”