SlideShare a Scribd company logo
1 of 31
Download to read offline
iOS TableViews Controllers /
Navigation Controllers
Lecture 05
Jonathan R. Engelsma, Ph.D.
TOPICS
• More onView Controllers
• Navigation Controllers
• TableView Overview
• StaticTableViews
• DynamicTableViews
VIEW CONTROLLERS
• We’ve seen previously that view controllers are the “glue”
between models and views. (e.g. looking inward)
• However, in addition to managing views & models, they also
communicate and coordinate with other view controllers
when UI transitions occur within the app. (e.g. looking outward)
• Storyboards make it much easier for us to handle these
outward looking concerns of view controllers.
VC RESPONSIBILITIES
• Making sure the view gets into the interface! Usually not the
managing view controller, but some other view controller…
• Provides animations as views appear/disappear.
• View Controllers work together to save / restore state, which
allow the app to restart if terminated or placed in the
background.
VC DATA MGMT GUIDELINES
• Unless self-contained, a destination view controller’s references
to app data should come from the source view controller.
• Use interface builder as much as possible!
• Always use a delegate to communicate back to other view
controllers. A view controller should not need to know the
type of its source view controller.
• Avoid unnecessary connections to objects external to your
view controller.
https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/ManagingDataFlowBetweenViewControllers/ManagingDataFlowBetweenViewControllers.html#//apple_ref/doc/uid/TP40007457-CH8-SW1
ROOTVIEW CONTROLLER
• The view controller that manages the view at the top of the
view hierarchy is know as the root view controller.
• Responsible for:
• handling rotation of the user interface
• manipulation of the status bar, present or not? light or dark
styling?
• There is only one root view controller in an app.
SUBORDINATE
RELATIONSHIPS
• Apps may consist of additional view controllers that are
subordinate to the root view controller.
• Subordinate relationships:
• parentage (containment)
• presentation (formally known as modal views)
PARENTAGE
• A view controller (parent) may contain a subordinate view
controller (child).
• A child view controller’s view, if visible is a subview of the
parent’s view.
• The parent view controller makes the views of its children
visible, or replaces with other views.
NAVIGATION CONTROLLERS
• Navigation controllers manage a stack of view controllers.
• Provide a drill-down interface for hierarchical content.
• Each view controller in the stack manages a distinct view.
• The navigation controller navigates within the stack of view
controllers.
UINavigationController
https://developer.apple.com/library/iOs/documentation/WindowsViews/Conceptual/ViewControllerCatalog/Chapters/NavigationControllers.html
NAV OBJECTS
• Stack is a LIFO collection of
view controllers.
• First item added to the stack
is known as the root view
controller.
HOWTO USE
• Using UINavigation Controller with Storyboards
1. Drag a UINavigationController from the object library
to the storyboard.
2. Cntrl-Click drag from nav controller to the “root” view.
3. Release click and select “root view”
4. In subsequent segues, make sure the type of the segue is
set to push.
PRESENTATION
RELATIONSHIP
• A view controller (presenting VC) can present another view
controller (presented VC)
• The presentedVC is NOT a child.
• The presentedVC’s view covers part or all of the presenting
VC’s view.
• Formally known (iOS 4 and earlier) as a modal view controller.
TABLEVIEWS IN IOS
• Table views have many purposes:
• To let users navigate through hierarchically structured data
• To present an indexed list of items
• To display detail information and controls in visually distinct
groupings
• To present a selectable list of options
UITABLEVIEW
• Multiple vertical rows, but only one column.
• Static or dynamic.
• Scrollable (inherits UIScrollView)
• Customized via a datasource and delegate protocol.
• Lots of different prefabricated layouts for the individual cells in
our UITableViews.
Dynamic / Plain
Indexed List
Static / Default
Layout / Grouped
Dynamic / Custom
Layout
Grouped Style
ATable Section
Disclosure Indicator
(indicates selecting
will navigate to a
new screen - often
the detail of that
row item.
ATable Header
ATable Footer
ATable Cell
Plain (ungrouped) Style
ATable Section
Disclosure Indicator
(indicates selecting
will navigate to a
new screen - often
the detail of that
row item.
ATable Header
ATable Footer
ATable Cell
UITableViewCellStyleDefault UITableViewCellStyleSubtitle UITableViewCellStyleValue2 UITableViewCellStyleValue1
CELL STYES
CONTROLLERS
• Most of the time we will manage UITableViews with
UITableViewControllers.
• Normally, the UITableView fills the entire view.
• Since the UITableView paradigm involves selecting a row to
“zoom” in on the details of that row, we need a way to
navigate back and forth between the table view and the detail
view.
• This is normally done with a Navigation Controller.
STATICTABLE DEMO
DEMO!!
DYNAMICTABLEVIEWS
• Static table views are great for use cases where the data is not
dynamic, such as setting screens, etc.
• If we are displaying data dynamically (e.g. displaying data
resulting from a DB query, or fetch to a web API.) we need to
use a different approach.
• We need to programmatically provide the UITableView with
its data!
UITABLEVIEW PROTOCOLS
• UITableView’s delegate and dataSource properties:
• dataSource (implements UITableViewDataSource): Mediates
the apps model data and the table view hierarchy (e.g.
specifies cells, headers, rows, etc.)
• delegate (implements UITableViewDelegate): manages how
the tableview will be displayed, row selection, etc.
UITABLEVIEW PROTOCOLS
• When we create a UITableViewController in Interface Builder:
• it has a property tableView that points to its UITableView
object.
• it automatically wires the controller object up to be the
delegate and dataSource.
UITABLEVIEWDATASOURCE
• Three important methods on UITableViewDataSource:
• numberOfSectionsInTableView: how many sections are in
the table?
• tableView:numberOfRowsInSection: how many rows are in
the given section?
• tableView:cellForRowAtIndexPath: provide a
IUTableViewCell for a given position within the table.
DYNAMICTABLE DEMO
DEMO!!
UITABLEVIEWDELEGATE
• The UITableView delegate handles a number of details
concerning how the table view will look.
• Handles what happens when a row is selected.
• We can also use it to edit the rows in a table view.
Table with 4 rows
Edit activated by
swiping from right to left
on the second row.
After delete is
pressed.
ROW EDIT DEMO
DEMO!!
READING ASSIGNMENT
• Chapter 6, 8: Programming
iOS 8 (by Neuburg)

More Related Content

Viewers also liked

2013 Michigan Beekeepers Association Annual Spring Conference
2013 Michigan Beekeepers Association Annual Spring Conference2013 Michigan Beekeepers Association Annual Spring Conference
2013 Michigan Beekeepers Association Annual Spring ConferenceJonathan Engelsma
 
Thinking in swift ppt
Thinking in swift pptThinking in swift ppt
Thinking in swift pptKeith Moon
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02) iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02) Jonathan Engelsma
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03) iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03) Jonathan Engelsma
 
Knowing Your Bees: Becoming a Better Beekeeper
Knowing Your Bees: Becoming a Better BeekeeperKnowing Your Bees: Becoming a Better Beekeeper
Knowing Your Bees: Becoming a Better BeekeeperJonathan Engelsma
 
2012 Michigan Beekeepers Association Annual Spring Conference - Beekeepers On...
2012 Michigan Beekeepers Association Annual Spring Conference - Beekeepers On...2012 Michigan Beekeepers Association Annual Spring Conference - Beekeepers On...
2012 Michigan Beekeepers Association Annual Spring Conference - Beekeepers On...Jonathan Engelsma
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 7)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 7)iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 7)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 7)Jonathan Engelsma
 
Beginning iOS Development with Swift
Beginning iOS Development with SwiftBeginning iOS Development with Swift
Beginning iOS Development with SwiftTurnToTech
 
Swift Programming Language
Swift Programming LanguageSwift Programming Language
Swift Programming LanguageGiuseppe Arici
 

Viewers also liked (9)

2013 Michigan Beekeepers Association Annual Spring Conference
2013 Michigan Beekeepers Association Annual Spring Conference2013 Michigan Beekeepers Association Annual Spring Conference
2013 Michigan Beekeepers Association Annual Spring Conference
 
Thinking in swift ppt
Thinking in swift pptThinking in swift ppt
Thinking in swift ppt
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02) iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 02)
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03) iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 03)
 
Knowing Your Bees: Becoming a Better Beekeeper
Knowing Your Bees: Becoming a Better BeekeeperKnowing Your Bees: Becoming a Better Beekeeper
Knowing Your Bees: Becoming a Better Beekeeper
 
2012 Michigan Beekeepers Association Annual Spring Conference - Beekeepers On...
2012 Michigan Beekeepers Association Annual Spring Conference - Beekeepers On...2012 Michigan Beekeepers Association Annual Spring Conference - Beekeepers On...
2012 Michigan Beekeepers Association Annual Spring Conference - Beekeepers On...
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 7)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 7)iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 7)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 7)
 
Beginning iOS Development with Swift
Beginning iOS Development with SwiftBeginning iOS Development with Swift
Beginning iOS Development with Swift
 
Swift Programming Language
Swift Programming LanguageSwift Programming Language
Swift Programming Language
 

Similar to iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 05)

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
 
Android and IOS UI Development (Android 5.0 and iOS 9.0)
Android and IOS UI Development (Android 5.0 and iOS 9.0)Android and IOS UI Development (Android 5.0 and iOS 9.0)
Android and IOS UI Development (Android 5.0 and iOS 9.0)Michael Shrove
 
Intro to UIKit • Made by Many
Intro to UIKit • Made by ManyIntro to UIKit • Made by Many
Intro to UIKit • Made by Manykenatmxm
 
Session 8 - Xcode 5 and interface builder for iOS 7 application
Session 8 - Xcode 5 and interface builder for iOS 7 applicationSession 8 - Xcode 5 and interface builder for iOS 7 application
Session 8 - Xcode 5 and interface builder for iOS 7 applicationVu Tran Lam
 
Building your first iOS app using Xamarin
Building your first iOS app using XamarinBuilding your first iOS app using Xamarin
Building your first iOS app using XamarinGill Cleeren
 
Session 13 - Working with navigation and tab bar
Session 13 - Working with navigation and tab barSession 13 - Working with navigation and tab bar
Session 13 - Working with navigation and tab barVu Tran Lam
 
Session 16 - Designing universal interface which used for iPad and iPhone
Session 16  -  Designing universal interface which used for iPad and iPhoneSession 16  -  Designing universal interface which used for iPad and iPhone
Session 16 - Designing universal interface which used for iPad and iPhoneVu Tran Lam
 
iOS Coding Best Practices
iOS Coding Best PracticesiOS Coding Best Practices
iOS Coding Best PracticesJean-Luc David
 
아이폰강의(4) pdf
아이폰강의(4) pdf아이폰강의(4) pdf
아이폰강의(4) pdfsunwooindia
 

Similar to iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 05) (20)

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
 
Android and IOS UI Development (Android 5.0 and iOS 9.0)
Android and IOS UI Development (Android 5.0 and iOS 9.0)Android and IOS UI Development (Android 5.0 and iOS 9.0)
Android and IOS UI Development (Android 5.0 and iOS 9.0)
 
Intro to UIKit • Made by Many
Intro to UIKit • Made by ManyIntro to UIKit • Made by Many
Intro to UIKit • Made by Many
 
Ui 5
Ui   5Ui   5
Ui 5
 
Session 8 - Xcode 5 and interface builder for iOS 7 application
Session 8 - Xcode 5 and interface builder for iOS 7 applicationSession 8 - Xcode 5 and interface builder for iOS 7 application
Session 8 - Xcode 5 and interface builder for iOS 7 application
 
Introduction of Xcode
Introduction of XcodeIntroduction of Xcode
Introduction of Xcode
 
Building your first iOS app using Xamarin
Building your first iOS app using XamarinBuilding your first iOS app using Xamarin
Building your first iOS app using Xamarin
 
Session 13 - Working with navigation and tab bar
Session 13 - Working with navigation and tab barSession 13 - Working with navigation and tab bar
Session 13 - Working with navigation and tab bar
 
iOS storyboard
iOS storyboardiOS storyboard
iOS storyboard
 
Session 16 - Designing universal interface which used for iPad and iPhone
Session 16  -  Designing universal interface which used for iPad and iPhoneSession 16  -  Designing universal interface which used for iPad and iPhone
Session 16 - Designing universal interface which used for iPad and iPhone
 
iOS: Table Views
iOS: Table ViewsiOS: Table Views
iOS: Table Views
 
iOS (7) Workshop
iOS (7) WorkshopiOS (7) Workshop
iOS (7) Workshop
 
Marionette talk 2016
Marionette talk 2016Marionette talk 2016
Marionette talk 2016
 
Mvc architecture
Mvc architectureMvc architecture
Mvc architecture
 
iOS Coding Best Practices
iOS Coding Best PracticesiOS Coding Best Practices
iOS Coding Best Practices
 
MVP Clean Architecture
MVP Clean  Architecture MVP Clean  Architecture
MVP Clean Architecture
 
아이폰강의(4) pdf
아이폰강의(4) pdf아이폰강의(4) pdf
아이폰강의(4) pdf
 
IOS APPs Revision
IOS APPs RevisionIOS APPs Revision
IOS APPs Revision
 
iOS training (intermediate)
iOS training (intermediate)iOS training (intermediate)
iOS training (intermediate)
 
Swift
SwiftSwift
Swift
 

More from Jonathan Engelsma

BIP Hive Scale Program Overview
BIP Hive Scale Program OverviewBIP Hive Scale Program Overview
BIP Hive Scale Program OverviewJonathan Engelsma
 
Selling Honey at Farmers Markets, Expos, etc.
Selling Honey at Farmers Markets, Expos, etc. Selling Honey at Farmers Markets, Expos, etc.
Selling Honey at Farmers Markets, Expos, etc. Jonathan Engelsma
 
Harvesting and Handling Honey for Hobby and Small Sideline Beekeepers
Harvesting and Handling Honey for Hobby and Small Sideline BeekeepersHarvesting and Handling Honey for Hobby and Small Sideline Beekeepers
Harvesting and Handling Honey for Hobby and Small Sideline BeekeepersJonathan Engelsma
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 09)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 09)iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 09)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 09)Jonathan Engelsma
 
So You Want To Be a Beekeeper?
So You Want To Be a Beekeeper? So You Want To Be a Beekeeper?
So You Want To Be a Beekeeper? Jonathan Engelsma
 

More from Jonathan Engelsma (6)

BIP Hive Scale Program Overview
BIP Hive Scale Program OverviewBIP Hive Scale Program Overview
BIP Hive Scale Program Overview
 
Selling Honey Online
Selling Honey OnlineSelling Honey Online
Selling Honey Online
 
Selling Honey at Farmers Markets, Expos, etc.
Selling Honey at Farmers Markets, Expos, etc. Selling Honey at Farmers Markets, Expos, etc.
Selling Honey at Farmers Markets, Expos, etc.
 
Harvesting and Handling Honey for Hobby and Small Sideline Beekeepers
Harvesting and Handling Honey for Hobby and Small Sideline BeekeepersHarvesting and Handling Honey for Hobby and Small Sideline Beekeepers
Harvesting and Handling Honey for Hobby and Small Sideline Beekeepers
 
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 09)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 09)iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 09)
iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 09)
 
So You Want To Be a Beekeeper?
So You Want To Be a Beekeeper? So You Want To Be a Beekeeper?
So You Want To Be a Beekeeper?
 

Recently uploaded

Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdfssuserdda66b
 
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
 
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
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfNirmal Dwivedi
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxVishalSingh1417
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxEsquimalt MFRC
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxDr. Sarita Anand
 
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
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Association for Project Management
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
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
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.christianmathematics
 
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
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxJisc
 
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
 

Recently uploaded (20)

Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
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
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
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
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptxHMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
HMCS Max Bernays Pre-Deployment Brief (May 2024).pptx
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
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
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
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)
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
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
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Towards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptxTowards a code of practice for AI in AT.pptx
Towards a code of practice for AI in AT.pptx
 
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
 

iOS Bootcamp: learning to create awesome apps on iOS using Swift (Lecture 05)

  • 1. iOS TableViews Controllers / Navigation Controllers Lecture 05 Jonathan R. Engelsma, Ph.D.
  • 2. TOPICS • More onView Controllers • Navigation Controllers • TableView Overview • StaticTableViews • DynamicTableViews
  • 3. VIEW CONTROLLERS • We’ve seen previously that view controllers are the “glue” between models and views. (e.g. looking inward) • However, in addition to managing views & models, they also communicate and coordinate with other view controllers when UI transitions occur within the app. (e.g. looking outward) • Storyboards make it much easier for us to handle these outward looking concerns of view controllers.
  • 4. VC RESPONSIBILITIES • Making sure the view gets into the interface! Usually not the managing view controller, but some other view controller… • Provides animations as views appear/disappear. • View Controllers work together to save / restore state, which allow the app to restart if terminated or placed in the background.
  • 5. VC DATA MGMT GUIDELINES • Unless self-contained, a destination view controller’s references to app data should come from the source view controller. • Use interface builder as much as possible! • Always use a delegate to communicate back to other view controllers. A view controller should not need to know the type of its source view controller. • Avoid unnecessary connections to objects external to your view controller. https://developer.apple.com/library/ios/featuredarticles/ViewControllerPGforiPhoneOS/ManagingDataFlowBetweenViewControllers/ManagingDataFlowBetweenViewControllers.html#//apple_ref/doc/uid/TP40007457-CH8-SW1
  • 6. ROOTVIEW CONTROLLER • The view controller that manages the view at the top of the view hierarchy is know as the root view controller. • Responsible for: • handling rotation of the user interface • manipulation of the status bar, present or not? light or dark styling? • There is only one root view controller in an app.
  • 7. SUBORDINATE RELATIONSHIPS • Apps may consist of additional view controllers that are subordinate to the root view controller. • Subordinate relationships: • parentage (containment) • presentation (formally known as modal views)
  • 8. PARENTAGE • A view controller (parent) may contain a subordinate view controller (child). • A child view controller’s view, if visible is a subview of the parent’s view. • The parent view controller makes the views of its children visible, or replaces with other views.
  • 9. NAVIGATION CONTROLLERS • Navigation controllers manage a stack of view controllers. • Provide a drill-down interface for hierarchical content. • Each view controller in the stack manages a distinct view. • The navigation controller navigates within the stack of view controllers.
  • 12. NAV OBJECTS • Stack is a LIFO collection of view controllers. • First item added to the stack is known as the root view controller.
  • 13. HOWTO USE • Using UINavigation Controller with Storyboards 1. Drag a UINavigationController from the object library to the storyboard. 2. Cntrl-Click drag from nav controller to the “root” view. 3. Release click and select “root view” 4. In subsequent segues, make sure the type of the segue is set to push.
  • 14. PRESENTATION RELATIONSHIP • A view controller (presenting VC) can present another view controller (presented VC) • The presentedVC is NOT a child. • The presentedVC’s view covers part or all of the presenting VC’s view. • Formally known (iOS 4 and earlier) as a modal view controller.
  • 15. TABLEVIEWS IN IOS • Table views have many purposes: • To let users navigate through hierarchically structured data • To present an indexed list of items • To display detail information and controls in visually distinct groupings • To present a selectable list of options
  • 16. UITABLEVIEW • Multiple vertical rows, but only one column. • Static or dynamic. • Scrollable (inherits UIScrollView) • Customized via a datasource and delegate protocol. • Lots of different prefabricated layouts for the individual cells in our UITableViews.
  • 17. Dynamic / Plain Indexed List Static / Default Layout / Grouped Dynamic / Custom Layout
  • 18. Grouped Style ATable Section Disclosure Indicator (indicates selecting will navigate to a new screen - often the detail of that row item. ATable Header ATable Footer ATable Cell
  • 19. Plain (ungrouped) Style ATable Section Disclosure Indicator (indicates selecting will navigate to a new screen - often the detail of that row item. ATable Header ATable Footer ATable Cell
  • 21. CONTROLLERS • Most of the time we will manage UITableViews with UITableViewControllers. • Normally, the UITableView fills the entire view. • Since the UITableView paradigm involves selecting a row to “zoom” in on the details of that row, we need a way to navigate back and forth between the table view and the detail view. • This is normally done with a Navigation Controller.
  • 23. DYNAMICTABLEVIEWS • Static table views are great for use cases where the data is not dynamic, such as setting screens, etc. • If we are displaying data dynamically (e.g. displaying data resulting from a DB query, or fetch to a web API.) we need to use a different approach. • We need to programmatically provide the UITableView with its data!
  • 24. UITABLEVIEW PROTOCOLS • UITableView’s delegate and dataSource properties: • dataSource (implements UITableViewDataSource): Mediates the apps model data and the table view hierarchy (e.g. specifies cells, headers, rows, etc.) • delegate (implements UITableViewDelegate): manages how the tableview will be displayed, row selection, etc.
  • 25. UITABLEVIEW PROTOCOLS • When we create a UITableViewController in Interface Builder: • it has a property tableView that points to its UITableView object. • it automatically wires the controller object up to be the delegate and dataSource.
  • 26. UITABLEVIEWDATASOURCE • Three important methods on UITableViewDataSource: • numberOfSectionsInTableView: how many sections are in the table? • tableView:numberOfRowsInSection: how many rows are in the given section? • tableView:cellForRowAtIndexPath: provide a IUTableViewCell for a given position within the table.
  • 28. UITABLEVIEWDELEGATE • The UITableView delegate handles a number of details concerning how the table view will look. • Handles what happens when a row is selected. • We can also use it to edit the rows in a table view.
  • 29. Table with 4 rows Edit activated by swiping from right to left on the second row. After delete is pressed.
  • 31. READING ASSIGNMENT • Chapter 6, 8: Programming iOS 8 (by Neuburg)