SlideShare uma empresa Scribd logo
1 de 21
Baixar para ler offline
Unit 4—Lesson 5:
Table Views
Table views
An instance of the UITableView class

A subclass of UIScrollView

• Displays a list of items

• Displays one or possibly thousands of data objects

• Presents vertical scrolling and single-column, multiple rows

• Provides customizable options
Types
Table views
Dynamic Static
When content changes When content doesn’t changes
Table view controllers
Anatomy of a table view
Two possible approaches to add table views:

• Add a table view instance directly to a view
controller’s view 

• Add a table view controller to your
storyboard
Table view styles
Anatomy of a table view
Plain Grouped
Table view cells (UITableViewCell)
Anatomy of a table view
tableView(_:accessoryButtonTappedForRowWith:)
Every row is represented with a table view cell
In editing mode, the cell content shrinks
Cell content Accessory view
Cell content Reordering controlEditing control
UITableViewCell properties
Anatomy of a table view
Cell property Description
textLabel UILabel for the title
detailTextLabel UILabel for the subtitle
imageView UIImageView for an image
UITableViewCell class defines three properties for cell content
UITableViewCellStyle
Anatomy of a table view
Storyboard name Programmatic enum name Displays
Basic .default textLabel, imageView
Subtitle .subtitle textlabel , detailTextLabel, imageView
Right detail .value1 textlabel , detailTextLabel, imageView
Left detail .value2 textLabel , detailTextLabel
Table view readability margins
Anatomy of a table view
Set tableView.cellLayoutMarginsFollowReadableWidth to true
AdjustedDefault
Index paths
Points to a specific row in a specific section

Accessible through the row and section properties 

• indexPath.row

• indexPath.section

Values are zero-based
Arrays and table views
Collection of similar data

Typically backed by a collection of model objects

var emojis: [Emoji]
[Emoji(symbol: Character("😀"), name: "Grinning Face", description: "A typical smiley face.",
usage: "happiness"),
Emoji(symbol: Character("😕"), name: "Confused Face", description: "A confused, puzzled face.",
usage: "unsure what to think; displeasure"),
Emoji(symbol: Character("😍"), name: "Heart Eyes", description: "A smiley face with hearts for
eyes.", usage: "love of something; attractive")]
Cell dequeueing
Arrays and table views
Table views only load visible cells

Saves memory

Allows for a smooth flow when scrolling 

let cell: UITableViewCell = tableView.dequeueReusableCell(withIdentifier: "Cell", for:
indexPath)
Table view protocols
Protocol Description
UITableViewDataSource Provides data for populating sections and rows
UITableViewDelegate (optional) Customizes appearance and behavior
Number of sections
Table view data source (UITableViewDataSource)
optional func numberOfSections(in tableView: UITableView)
-> Int
If function isn’t provided, the table view assumes
one section
Number of rows in a section
Table view data source (UITableViewDataSource)
func tableView(_ tableView: UITableView,

numberOfRowsInSection section: Int) -> Int
Cell for row at index path
Table view data source (UITableViewDataSource)
func tableView(_ tableView: UITableView, 

cellForRowAt indexPath: IndexPath) -> UITableViewCell
Optional
Table view delegate (UITableViewDelegate)
Responding to accessory view interaction

tableView(_:accessoryButtonTappedForRowWith:)
Responding to user interaction

tableView(_:didSelectRowAt:)
Reload data
reloadData()
To force a data refresh
Table Views
Unit 4—Lesson 5
Learn how to create dynamic table views by
creating an emoji dictionary app
Lab: Meal Tracker
Unit 4—Lesson 5
Practice with the UITableViewDataSource and UITableViewController by
creating an app that will display a list of foods, grouped into three sections, one for
each meal of the day
© 2017 Apple Inc. 

This work is licensed by Apple Inc. under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International license.

Mais conteúdo relacionado

Mais procurados (20)

Low Level View of Android System Architecture
Low Level View of Android System ArchitectureLow Level View of Android System Architecture
Low Level View of Android System Architecture
 
Intro to UIKit • Made by Many
Intro to UIKit • Made by ManyIntro to UIKit • Made by Many
Intro to UIKit • Made by Many
 
Интерфейсы
ИнтерфейсыИнтерфейсы
Интерфейсы
 
Fly Weight Design Pattern.pptx
Fly Weight Design Pattern.pptxFly Weight Design Pattern.pptx
Fly Weight Design Pattern.pptx
 
Android Development - ConstraintLayout
Android Development - ConstraintLayoutAndroid Development - ConstraintLayout
Android Development - ConstraintLayout
 
Flutter state management from zero to hero
Flutter state management from zero to heroFlutter state management from zero to hero
Flutter state management from zero to hero
 
ASP.MVC Training
ASP.MVC TrainingASP.MVC Training
ASP.MVC Training
 
Domain-driven design - eine Einführung
Domain-driven design - eine EinführungDomain-driven design - eine Einführung
Domain-driven design - eine Einführung
 
[Android] Widget Event Handling
[Android] Widget Event Handling[Android] Widget Event Handling
[Android] Widget Event Handling
 
Ios development
Ios developmentIos development
Ios development
 
Basic overview of Angular
Basic overview of AngularBasic overview of Angular
Basic overview of Angular
 
Angular Lifecycle Hooks
Angular Lifecycle HooksAngular Lifecycle Hooks
Angular Lifecycle Hooks
 
AEM Sightly Deep Dive
AEM Sightly Deep DiveAEM Sightly Deep Dive
AEM Sightly Deep Dive
 
Android Binder IPC for Linux
Android Binder IPC for LinuxAndroid Binder IPC for Linux
Android Binder IPC for Linux
 
API Basics
API BasicsAPI Basics
API Basics
 
React Native - Getting Started
React Native - Getting StartedReact Native - Getting Started
React Native - Getting Started
 
Flyweight pattern
Flyweight patternFlyweight pattern
Flyweight pattern
 
Introdução ao Spring Framework MVC
Introdução ao Spring Framework MVCIntrodução ao Spring Framework MVC
Introdução ao Spring Framework MVC
 
Java & J2EE Coding Conventions
Java & J2EE Coding ConventionsJava & J2EE Coding Conventions
Java & J2EE Coding Conventions
 
Abap reports
Abap reportsAbap reports
Abap reports
 

Semelhante a Table views

Session 14 - Working with table view and search bar
Session 14 - Working with table view and search barSession 14 - Working with table view and search bar
Session 14 - Working with table view and search barVu Tran Lam
 
Intermediate table views
Intermediate table viewsIntermediate table views
Intermediate table viewsSV.CO
 
MS EXCEL INTRODUCTION DISCUSSING ALL FEATURES.ppt
MS EXCEL INTRODUCTION DISCUSSING ALL FEATURES.pptMS EXCEL INTRODUCTION DISCUSSING ALL FEATURES.ppt
MS EXCEL INTRODUCTION DISCUSSING ALL FEATURES.pptpkm16499
 
04.Navigation on Windows Phone
04.Navigation on Windows Phone04.Navigation on Windows Phone
04.Navigation on Windows PhoneNguyen Tuan
 
Microsoft excel training
Microsoft excel trainingMicrosoft excel training
Microsoft excel trainingEmilyE120
 
It presentation
It presentationIt presentation
It presentationmithu mehr
 
Smooth scrolling in UITableView and UICollectionView
Smooth scrolling in UITableView and UICollectionViewSmooth scrolling in UITableView and UICollectionView
Smooth scrolling in UITableView and UICollectionViewAndrea Prearo
 

Semelhante a Table views (19)

Table views
Table viewsTable views
Table views
 
Session 14 - Working with table view and search bar
Session 14 - Working with table view and search barSession 14 - Working with table view and search bar
Session 14 - Working with table view and search bar
 
Excel Tables.pdf
Excel Tables.pdfExcel Tables.pdf
Excel Tables.pdf
 
занятие7
занятие7занятие7
занятие7
 
Intermediate table views
Intermediate table viewsIntermediate table views
Intermediate table views
 
Java presentation
Java presentationJava presentation
Java presentation
 
EXCEL
EXCELEXCEL
EXCEL
 
MS EXCEL INTRODUCTION DISCUSSING ALL FEATURES.ppt
MS EXCEL INTRODUCTION DISCUSSING ALL FEATURES.pptMS EXCEL INTRODUCTION DISCUSSING ALL FEATURES.ppt
MS EXCEL INTRODUCTION DISCUSSING ALL FEATURES.ppt
 
04.Navigation on Windows Phone
04.Navigation on Windows Phone04.Navigation on Windows Phone
04.Navigation on Windows Phone
 
Microsoft excel training
Microsoft excel trainingMicrosoft excel training
Microsoft excel training
 
Ms excell
Ms excellMs excell
Ms excell
 
It presentation
It presentationIt presentation
It presentation
 
MS EXCEL
MS EXCELMS EXCEL
MS EXCEL
 
Dreamweaver Ch05
Dreamweaver Ch05Dreamweaver Ch05
Dreamweaver Ch05
 
Html tables
Html tablesHtml tables
Html tables
 
Smooth scrolling in UITableView and UICollectionView
Smooth scrolling in UITableView and UICollectionViewSmooth scrolling in UITableView and UICollectionView
Smooth scrolling in UITableView and UICollectionView
 
Vertica-Database
Vertica-DatabaseVertica-Database
Vertica-Database
 
iOS: Table Views
iOS: Table ViewsiOS: Table Views
iOS: Table Views
 
MS Excel 2013
MS Excel 2013MS Excel 2013
MS Excel 2013
 

Mais de SV.CO

Handout level-1-module-1
Handout   level-1-module-1Handout   level-1-module-1
Handout level-1-module-1SV.CO
 
Persistence And Documents
Persistence And DocumentsPersistence And Documents
Persistence And DocumentsSV.CO
 
Building complex input screens
Building complex input screensBuilding complex input screens
Building complex input screensSV.CO
 
Working with the Web: 
Decoding JSON
Working with the Web: 
Decoding JSONWorking with the Web: 
Decoding JSON
Working with the Web: 
Decoding JSONSV.CO
 
Saving Data
Saving DataSaving Data
Saving DataSV.CO
 
Alerts notification
Alerts notificationAlerts notification
Alerts notificationSV.CO
 
UI Dynamics
UI DynamicsUI Dynamics
UI DynamicsSV.CO
 
Practical animation
Practical animationPractical animation
Practical animationSV.CO
 
Segues and navigation controllers
Segues and navigation controllersSegues and navigation controllers
Segues and navigation controllersSV.CO
 
Camera And Email
Camera And EmailCamera And Email
Camera And EmailSV.CO
 
Scroll views
Scroll viewsScroll views
Scroll viewsSV.CO
 
Closures
ClosuresClosures
ClosuresSV.CO
 
Protocols
ProtocolsProtocols
ProtocolsSV.CO
 
App anatomy and life cycle
App anatomy and life cycleApp anatomy and life cycle
App anatomy and life cycleSV.CO
 
Extensions
ExtensionsExtensions
ExtensionsSV.CO
 
Gestures
GesturesGestures
GesturesSV.CO
 
View controller life cycle
View controller life cycleView controller life cycle
View controller life cycleSV.CO
 
Controls in action
Controls in actionControls in action
Controls in actionSV.CO
 
Auto layout and stack views
Auto layout and stack viewsAuto layout and stack views
Auto layout and stack viewsSV.CO
 
Custom view
Custom viewCustom view
Custom viewSV.CO
 

Mais de SV.CO (20)

Handout level-1-module-1
Handout   level-1-module-1Handout   level-1-module-1
Handout level-1-module-1
 
Persistence And Documents
Persistence And DocumentsPersistence And Documents
Persistence And Documents
 
Building complex input screens
Building complex input screensBuilding complex input screens
Building complex input screens
 
Working with the Web: 
Decoding JSON
Working with the Web: 
Decoding JSONWorking with the Web: 
Decoding JSON
Working with the Web: 
Decoding JSON
 
Saving Data
Saving DataSaving Data
Saving Data
 
Alerts notification
Alerts notificationAlerts notification
Alerts notification
 
UI Dynamics
UI DynamicsUI Dynamics
UI Dynamics
 
Practical animation
Practical animationPractical animation
Practical animation
 
Segues and navigation controllers
Segues and navigation controllersSegues and navigation controllers
Segues and navigation controllers
 
Camera And Email
Camera And EmailCamera And Email
Camera And Email
 
Scroll views
Scroll viewsScroll views
Scroll views
 
Closures
ClosuresClosures
Closures
 
Protocols
ProtocolsProtocols
Protocols
 
App anatomy and life cycle
App anatomy and life cycleApp anatomy and life cycle
App anatomy and life cycle
 
Extensions
ExtensionsExtensions
Extensions
 
Gestures
GesturesGestures
Gestures
 
View controller life cycle
View controller life cycleView controller life cycle
View controller life cycle
 
Controls in action
Controls in actionControls in action
Controls in action
 
Auto layout and stack views
Auto layout and stack viewsAuto layout and stack views
Auto layout and stack views
 
Custom view
Custom viewCustom view
Custom view
 

Último

Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Jisc
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...pradhanghanshyam7136
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseAnaAcapella
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxheathfieldcps1
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin ClassesCeline George
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17Celine George
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxAmanpreet Kaur
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxRamakrishna Reddy Bijjam
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxVishalSingh1417
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 

Último (20)

Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17  How to Extend Models Using Mixin ClassesMixin Classes in Odoo 17  How to Extend Models Using Mixin Classes
Mixin Classes in Odoo 17 How to Extend Models Using Mixin Classes
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 

Table views

  • 2. Table views An instance of the UITableView class A subclass of UIScrollView • Displays a list of items • Displays one or possibly thousands of data objects • Presents vertical scrolling and single-column, multiple rows • Provides customizable options
  • 3. Types Table views Dynamic Static When content changes When content doesn’t changes
  • 4. Table view controllers Anatomy of a table view Two possible approaches to add table views: • Add a table view instance directly to a view controller’s view • Add a table view controller to your storyboard
  • 5. Table view styles Anatomy of a table view Plain Grouped
  • 6. Table view cells (UITableViewCell) Anatomy of a table view tableView(_:accessoryButtonTappedForRowWith:) Every row is represented with a table view cell In editing mode, the cell content shrinks Cell content Accessory view Cell content Reordering controlEditing control
  • 7. UITableViewCell properties Anatomy of a table view Cell property Description textLabel UILabel for the title detailTextLabel UILabel for the subtitle imageView UIImageView for an image UITableViewCell class defines three properties for cell content
  • 8. UITableViewCellStyle Anatomy of a table view Storyboard name Programmatic enum name Displays Basic .default textLabel, imageView Subtitle .subtitle textlabel , detailTextLabel, imageView Right detail .value1 textlabel , detailTextLabel, imageView Left detail .value2 textLabel , detailTextLabel
  • 9. Table view readability margins Anatomy of a table view Set tableView.cellLayoutMarginsFollowReadableWidth to true AdjustedDefault
  • 10. Index paths Points to a specific row in a specific section Accessible through the row and section properties • indexPath.row • indexPath.section Values are zero-based
  • 11. Arrays and table views Collection of similar data Typically backed by a collection of model objects var emojis: [Emoji] [Emoji(symbol: Character("😀"), name: "Grinning Face", description: "A typical smiley face.", usage: "happiness"), Emoji(symbol: Character("😕"), name: "Confused Face", description: "A confused, puzzled face.", usage: "unsure what to think; displeasure"), Emoji(symbol: Character("😍"), name: "Heart Eyes", description: "A smiley face with hearts for eyes.", usage: "love of something; attractive")]
  • 12. Cell dequeueing Arrays and table views Table views only load visible cells Saves memory Allows for a smooth flow when scrolling let cell: UITableViewCell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
  • 13. Table view protocols Protocol Description UITableViewDataSource Provides data for populating sections and rows UITableViewDelegate (optional) Customizes appearance and behavior
  • 14. Number of sections Table view data source (UITableViewDataSource) optional func numberOfSections(in tableView: UITableView) -> Int If function isn’t provided, the table view assumes one section
  • 15. Number of rows in a section Table view data source (UITableViewDataSource) func tableView(_ tableView: UITableView,
 numberOfRowsInSection section: Int) -> Int
  • 16. Cell for row at index path Table view data source (UITableViewDataSource) func tableView(_ tableView: UITableView, 
 cellForRowAt indexPath: IndexPath) -> UITableViewCell
  • 17. Optional Table view delegate (UITableViewDelegate) Responding to accessory view interaction tableView(_:accessoryButtonTappedForRowWith:) Responding to user interaction tableView(_:didSelectRowAt:)
  • 19. Table Views Unit 4—Lesson 5 Learn how to create dynamic table views by creating an emoji dictionary app
  • 20. Lab: Meal Tracker Unit 4—Lesson 5 Practice with the UITableViewDataSource and UITableViewController by creating an app that will display a list of foods, grouped into three sections, one for each meal of the day
  • 21. © 2017 Apple Inc. This work is licensed by Apple Inc. under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International license.