UITableView Research Flashcards
The UITableView Data Source is a ________ that [does what], and is responsible for _________.
The UITableView Data Source is a Protocol that provides the methods we need to setup a TableView properly, and is responsible for configuring cells.
What is a DataSource?
A DataSource is the object where all of the data that we want to display is held.
( Hint: If we are trying to display an Array of “Customers” that is located in our “ViewController”, then our DataSource is our ViewController. )
True or False: Our DataSource IS the JSON data, or model objects.
False – Our DataSource is NOT the JSON data, or model objects.
Where is our DataSource, generally?
Generally, our data source is where we have a collection of model objects.
(Tip: So far, this has been in our ViewController, but it doesn’t have to be.)
What is the UITableView Delegate responsible for?
Hint: There are 3 answers.
The UITableView Delegate is a protocol responsible for:
- Managing cell selection
- Managing table and cell dimensions
- Managing cell accessories interaction
What does the UITableView Delegate protocol do?
Provides us with methods we need to operate a TableView
IndexPath: What is it?
Tells us where in our TableView a certain cell is located.
True or False:
IndexPath contains both the section and row properties.
True.
Ex: A cell’s IndexPath might tell us for instance that a cell is in section 0 at row 5.
Why is an IndexPath important?
This is important for looping through cells in order to display information among other things.
Important Protocol Methods:
cellForRowAt
Responsible for cell creation and recycling
Important Protocol Methods:
numberOfRowsInSection
Tells the tableView how many cells it has
Important Protocol Methods:
didSelectRowAt
A specified cell was tapped
Important Protocol Methods:
accessoryButtonTappedForRowWithIndexPath
An Accessory button was tapped
UITableViews are made up of what?
A collection of UITableViewCells
What are cells type defined by?
Identifiers
Default Cell Components are:
Hint: 2 answers
- The Cell Content Area
- Accessory View
What makes up the Cell Content Area?
- imageView – Always appears on the left before any label
- textLabel – Basic text label, left aligned
- detailTextLabel – Secondary text label, position based on style
UITableViewCellStyle.Default
Text label (black and left-aligned), image view is optional
UITableViewCellStyle.Value1
Text label (black and left-aligned), detail text label (blue and right-aligned).
UITableViewCellStyle.Value2
Text label (blue and right-aligned), detail text label (black and left-aligned).
UITableViewCellStyle.Subtitle
Text label (black and left-aligned, top of cell), detail text label (grey and left-aligned, bottom of cell, smaller text).
Accessory Views:
case none
The cell does not have any accessory view. This is the default value.
Accessory Views:
case disclosureIndicator
The cell has an accessory control shaped like a chevron. This control indicates that tapping the cell triggers a push action. The control does not track touches.
Accessory Views:
case detailDisclosureButton
The cell has an info button and a chevron image as content. This control indicates that tapping the cell allows the user to configure the cell’s contents. The control tracks touches.
Accessory Views:
case checkmark
The cell has a check mark in its right side. This control does not track touches. The delegate of the table view can manage check marks in a section of rows (possibly limiting the check mark to one row of the section) in its tableView(_:didSelectRowAt:) method.
Accessory Views:
case detailButton
The cell has an info button without a chevron. This control indicates that tapping the cell displays additional information about the cell’s contents. The control tracks touches.