Protocol

UITable​View​Delegate

The delegate of a UITable​View object must adopt the UITable​View​Delegate protocol. Optional methods of the protocol allow the delegate to manage selections, configure section headings and footers, help to delete and reorder cells, and perform other actions.

Overview

Many methods of the UITable​View​Delegate protocol take NSIndex​Path objects as parameters and return values. UIKit declares a category on NSIndex​Path that enables you to get the represented row index (row property) and section index (section property), and to construct an index path from a given row index and section index (init(row:​section:​) method). Because rows are located within their sections, you usually must evaluate the section index number before you can identify the row by its index number.

Symbols

Configuring Rows for the Table View

func table​View(UITable​View, height​For​Row​At:​ Index​Path)

Asks the delegate for the height to use for a row in a specified location.

func table​View(UITable​View, estimated​Height​For​Row​At:​ Index​Path)

Asks the delegate for the estimated height of a row in a specified location.

func table​View(UITable​View, indentation​Level​For​Row​At:​ Index​Path)

Asks the delegate to return the level of indentation for a row in a given section.

func table​View(UITable​View, will​Display:​ UITable​View​Cell, for​Row​At:​ Index​Path)

Tells the delegate the table view is about to draw a cell for a particular row.

Managing Accessory Views

func table​View(UITable​View, edit​Actions​For​Row​At:​ Index​Path)

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

func table​View(UITable​View, accessory​Button​Tapped​For​Row​With:​ Index​Path)

Tells the delegate that the user tapped the accessory (disclosure) view associated with a given row.

Managing Selections

func table​View(UITable​View, will​Select​Row​At:​ Index​Path)

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

func table​View(UITable​View, did​Select​Row​At:​ Index​Path)

Tells the delegate that the specified row is now selected.

func table​View(UITable​View, will​Deselect​Row​At:​ Index​Path)

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

func table​View(UITable​View, did​Deselect​Row​At:​ Index​Path)

Tells the delegate that the specified row is now deselected.

Modifying the Header and Footer of Sections

func table​View(UITable​View, view​For​Header​In​Section:​ Int)

Asks the delegate for a view object to display in the header of the specified section of the table view.

func table​View(UITable​View, view​For​Footer​In​Section:​ Int)

Asks the delegate for a view object to display in the footer of the specified section of the table view.

func table​View(UITable​View, height​For​Header​In​Section:​ Int)

Asks the delegate for the height to use for the header of a particular section.

func table​View(UITable​View, estimated​Height​For​Header​In​Section:​ Int)

Asks the delegate for the estimated height of the header of a particular section.

func table​View(UITable​View, height​For​Footer​In​Section:​ Int)

Asks the delegate for the height to use for the footer of a particular section.

func table​View(UITable​View, estimated​Height​For​Footer​In​Section:​ Int)

Asks the delegate for the estimated height of the footer of a particular section.

func table​View(UITable​View, will​Display​Header​View:​ UIView, for​Section:​ Int)

Tells the delegate that a header view is about to be displayed for the specified section.

func table​View(UITable​View, will​Display​Footer​View:​ UIView, for​Section:​ Int)

Tells the delegate that a footer view is about to be displayed for the specified section.

Editing Table Rows

func table​View(UITable​View, will​Begin​Editing​Row​At:​ Index​Path)

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

func table​View(UITable​View, did​End​Editing​Row​At:​ Index​Path?)

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

func table​View(UITable​View, editing​Style​For​Row​At:​ Index​Path)

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

func table​View(UITable​View, should​Indent​While​Editing​Row​At:​ Index​Path)

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

Reordering Table Rows

Tracking the Removal of Views

func table​View(UITable​View, did​End​Displaying​Header​View:​ UIView, for​Section:​ Int)

Tells the delegate that the specified header view was removed from the table.

func table​View(UITable​View, did​End​Displaying​Footer​View:​ UIView, for​Section:​ Int)

Tells the delegate that the specified footer view was removed from the table.

Copying and Pasting Row Content

func table​View(UITable​View, should​Show​Menu​For​Row​At:​ Index​Path)

Asks the delegate if the editing menu should be shown for a certain row.

func table​View(UITable​View, can​Perform​Action:​ Selector, for​Row​At:​ Index​Path, with​Sender:​ Any?)

Asks the delegate if the editing menu should omit the Copy or Paste command for a given row.

func table​View(UITable​View, perform​Action:​ Selector, for​Row​At:​ Index​Path, with​Sender:​ Any?)

Tells the delegate to perform a copy or paste operation on the content of a given row.

Managing Table View Highlighting

func table​View(UITable​View, should​Highlight​Row​At:​ Index​Path)

Asks the delegate if the specified row should be highlighted.

func table​View(UITable​View, did​Highlight​Row​At:​ Index​Path)

Tells the delegate that the specified row was highlighted.

func table​View(UITable​View, did​Unhighlight​Row​At:​ Index​Path)

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

Managing Table View Focus

func table​View(UITable​View, can​Focus​Row​At:​ Index​Path)

Asks the delegate whether the cell at the specified index path is itself focusable.

func table​View(UITable​View, should​Update​Focus​In:​ UITable​View​Focus​Update​Context)

Asks the delegate whether the focus update specified by the context is allowed to occur.

func index​Path​For​Preferred​Focused​View(in:​ UITable​View)

Asks the delegate for the table view’s index path for the preferred focused view.