SlideShare a Scribd company logo
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.

More Related Content

What's hot

UDA-Componentes RUP. Autocomplete
UDA-Componentes RUP. AutocompleteUDA-Componentes RUP. Autocomplete
UDA-Componentes RUP. Autocomplete
Ander Martinez
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
Prarthan P
 
Angular 5 presentation for beginners
Angular 5 presentation for beginnersAngular 5 presentation for beginners
Angular 5 presentation for beginners
Imran Qasim
 
Angular Dependency Injection
Angular Dependency InjectionAngular Dependency Injection
Angular Dependency Injection
Nir Kaufman
 
ASP.NET 10 - Data Controls
ASP.NET 10 - Data ControlsASP.NET 10 - Data Controls
ASP.NET 10 - Data Controls
Randy Connolly
 
Jetpack Compose.pptx
Jetpack Compose.pptxJetpack Compose.pptx
Jetpack Compose.pptx
GDSCVJTI
 
Kotlin Jetpack Tutorial
Kotlin Jetpack TutorialKotlin Jetpack Tutorial
Kotlin Jetpack Tutorial
Simplilearn
 
Introduction to java beans
Introduction to java beansIntroduction to java beans
Introduction to java beans
Hitesh Parmar
 
Spring ppt
Spring pptSpring ppt
Spring ppt
Mumbai Academisc
 
Java Collections Framework
Java Collections FrameworkJava Collections Framework
Java Collections Framework
Sony India Software Center
 
C sharp
C sharpC sharp
C sharp
sanjay joshi
 
Introduction to JSON
Introduction to JSONIntroduction to JSON
Introduction to JSON
Kanda Runapongsa Saikaew
 
Generics and collections in Java
Generics and collections in JavaGenerics and collections in Java
Generics and collections in Java
Gurpreet singh
 
Bootstrap PPT by Mukesh
Bootstrap PPT by MukeshBootstrap PPT by Mukesh
Bootstrap PPT by Mukesh
Mukesh Kumar
 
Collections In Java
Collections In JavaCollections In Java
Collections In JavaBinoj T E
 
Angular 8
Angular 8 Angular 8
Angular 8
Sunil OS
 
What’s New in Angular 14?
What’s New in Angular 14?What’s New in Angular 14?
What’s New in Angular 14?
Albiorix Technology
 
sets and maps
 sets and maps sets and maps
sets and maps
Rajkattamuri
 
Kotlin Basics & Introduction to Jetpack Compose.pptx
Kotlin Basics & Introduction to Jetpack Compose.pptxKotlin Basics & Introduction to Jetpack Compose.pptx
Kotlin Basics & Introduction to Jetpack Compose.pptx
takshilkunadia
 

What's hot (20)

UDA-Componentes RUP. Autocomplete
UDA-Componentes RUP. AutocompleteUDA-Componentes RUP. Autocomplete
UDA-Componentes RUP. Autocomplete
 
Introduction to CSS
Introduction to CSSIntroduction to CSS
Introduction to CSS
 
Angular 5 presentation for beginners
Angular 5 presentation for beginnersAngular 5 presentation for beginners
Angular 5 presentation for beginners
 
Angular Dependency Injection
Angular Dependency InjectionAngular Dependency Injection
Angular Dependency Injection
 
ASP.NET 10 - Data Controls
ASP.NET 10 - Data ControlsASP.NET 10 - Data Controls
ASP.NET 10 - Data Controls
 
Jetpack Compose.pptx
Jetpack Compose.pptxJetpack Compose.pptx
Jetpack Compose.pptx
 
Kotlin Jetpack Tutorial
Kotlin Jetpack TutorialKotlin Jetpack Tutorial
Kotlin Jetpack Tutorial
 
Introduction to java beans
Introduction to java beansIntroduction to java beans
Introduction to java beans
 
Spring ppt
Spring pptSpring ppt
Spring ppt
 
Java Collections Framework
Java Collections FrameworkJava Collections Framework
Java Collections Framework
 
Html-list
Html-listHtml-list
Html-list
 
C sharp
C sharpC sharp
C sharp
 
Introduction to JSON
Introduction to JSONIntroduction to JSON
Introduction to JSON
 
Generics and collections in Java
Generics and collections in JavaGenerics and collections in Java
Generics and collections in Java
 
Bootstrap PPT by Mukesh
Bootstrap PPT by MukeshBootstrap PPT by Mukesh
Bootstrap PPT by Mukesh
 
Collections In Java
Collections In JavaCollections In Java
Collections In Java
 
Angular 8
Angular 8 Angular 8
Angular 8
 
What’s New in Angular 14?
What’s New in Angular 14?What’s New in Angular 14?
What’s New in Angular 14?
 
sets and maps
 sets and maps sets and maps
sets and maps
 
Kotlin Basics & Introduction to Jetpack Compose.pptx
Kotlin Basics & Introduction to Jetpack Compose.pptxKotlin Basics & Introduction to Jetpack Compose.pptx
Kotlin Basics & Introduction to Jetpack Compose.pptx
 

Similar to 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 views
SV.CO
 
Java presentation
Java presentationJava presentation
Java presentation
nazmul sharif
 
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
pkm16499
 
04.Navigation on Windows Phone
04.Navigation on Windows Phone04.Navigation on Windows Phone
04.Navigation on Windows Phone
Nguyen Tuan
 
Microsoft excel training
Microsoft excel trainingMicrosoft excel training
Microsoft excel trainingEmilyE120
 
Ms excell
Ms excellMs excell
Ms excell
usmankhaliq6
 
It presentation
It presentationIt presentation
It presentationmithu mehr
 
MS EXCEL
MS EXCELMS EXCEL
MS EXCEL
syed_umar
 
Html tables
Html tablesHtml tables
Smooth scrolling in UITableView and UICollectionView
Smooth scrolling in UITableView and UICollectionViewSmooth scrolling in UITableView and UICollectionView
Smooth scrolling in UITableView and UICollectionView
Andrea Prearo
 
MS Excel 2013
MS Excel 2013MS Excel 2013
MS Excel 2013
Jahnavee Parmar
 

Similar to 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
 

More from SV.CO

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

More from 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
 

Recently uploaded

The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
DhatriParmar
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
camakaiclarkmusic
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
heathfieldcps1
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Atul Kumar Singh
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
TechSoup
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
EduSkills OECD
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
Levi Shapiro
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
Jean Carlos Nunes Paixão
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
Peter Windle
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
CarlosHernanMontoyab2
 

Recently uploaded (20)

The Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptxThe Accursed House by Émile Gaboriau.pptx
The Accursed House by Émile Gaboriau.pptx
 
CACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdfCACJapan - GROUP Presentation 1- Wk 4.pdf
CACJapan - GROUP Presentation 1- Wk 4.pdf
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
The basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptxThe basics of sentences session 5pptx.pptx
The basics of sentences session 5pptx.pptx
 
Guidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th SemesterGuidance_and_Counselling.pdf B.Ed. 4th Semester
Guidance_and_Counselling.pdf B.Ed. 4th Semester
 
Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Introduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp NetworkIntroduction to AI for Nonprofits with Tapp Network
Introduction to AI for Nonprofits with Tapp Network
 
Francesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptxFrancesca Gottschalk - How can education support child empowerment.pptx
Francesca Gottschalk - How can education support child empowerment.pptx
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Lapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdfLapbook sobre os Regimes Totalitários.pdf
Lapbook sobre os Regimes Totalitários.pdf
 
Embracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic ImperativeEmbracing GenAI - A Strategic Imperative
Embracing GenAI - A Strategic Imperative
 
678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf678020731-Sumas-y-Restas-Para-Colorear.pdf
678020731-Sumas-y-Restas-Para-Colorear.pdf
 

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.