Tables. Mobile Application Development in ios School of EECS Washington State University Instructor: Larry Holder

Similar documents
ITP 342 Mobile App Dev. Table Views

Chapter 22 TableView TableView. TableView ios. ViewController. Cell TableViewCell TableView

ITP 342 Mobile App Dev. Table Views

App. Chapter 19 App. App (ViewController) App. Single View Application Single View Application View. (View Controller)

Stanford CS193p. Developing Applications for ios. Fall CS193p. Fall

Navigation and Segues

Introductory ios Development

Document Version Date: 1st March, 2015

UI Design and Storyboarding

News- ipad: ios(swift) Application

Stanford CS193p. Developing Applications for ios. Winter CS193p! Winter 2015

Social Pinboard: ios(swift) Application

ios Mobile Development

Enhancing your apps for the next dimension of touch

ios Development - Xcode IDE

This book contains code samples available under the MIT License, printed below:

Produced by. Design Patterns. MSc in Computer Science. Eamonn de Leastar

Protocols and Delegates. Dr. Sarah Abraham

Mobile Development - Lab 2

Building the App - Part 5 - Adding a Link

A Mad Libs app that you will navigate through 3 UIViewControllers to add text that will be shown in a story on the fourth UIViewController.

Gestures. Mobile Application Development in ios School of EECS Washington State University Instructor: Larry Holder

COMPLETE TUTORIAL COURSE. Learn to make tvos LE. apps with real-worldam S F

Collection Views. Dr. Sarah Abraham

Lecture 8 Demo Code: Cassini Multithreading

Apple Development Technology Workshops

Praktikum Entwicklung von Mediensystemen mit

Implementing UI Designs in Interface Builder

Miscellaneous Topics

ITP 342 Mobile App Dev. Connections

Structuring an App Copyright 2013 Apple Inc. All Rights Reserved.

imate: ios Application

ITP 342 Mobile App Dev. Web View

Today s Topics. Scroll views Table views. UITableViewController Table view cells. Displaying data Controlling appearance & behavior

MVC & Onwards. CS 442: Mobile App Development Michael Saelee

CS193P - Lecture 8. iphone Application Development. Scroll Views & Table Views

Naviga&on and Tab Bar Controllers and Table View

Learn to make ios apps

ITP 342 Mobile App Dev. Collection View

Rx in the real world. 1 Rob Ciolli

ITP 342 Mobile App Dev. Delegates

Notifications. Mobile Application Development in ios School of EECS Washington State University Instructor: Larry Holder

User Interfaces. Lecture 15. Application Programming on Mac OS. Hamza Bennani September 4, 2018

Multimedia. Mobile Application Development in ios School of EECS Washington State University Instructor: Larry Holder

Index. btndrop function, 224, 226 btngetquote function, 246 btnpressed function, 28 btnquote method, 245. CallWeb method, 238, 240

} override func didreceivememorywarning() { 26 super.didreceivememorywarning() 27 } 28 } Pause Stop

Sensors. Mobile Application Development in ios School of EECS Washington State University Instructor: Larry Holder

Data Storage. Mobile Application Development in ios School of EECS Washington State University Instructor: Larry Holder

IPhone Application of Carleton University. Carleton University Computer Science Honors Project Report

MVC and Interface Builder IAP 2010

Stanford CS193p. Developing Applications for ios. Fall Stanford CS193p. Fall 2011

DÉVELOPPER UNE APPLICATION IOS

View Controllers CPRE 388

Building Mapping Apps for ios With Swift

Data Storage. Mobile Application Development in ios School of EECS Washington State University Instructor: Larry Holder

Settings. Mobile Application Development in ios School of EECS Washington State University Instructor: Larry Holder

InterfaceBuilder and user interfaces

Stanford CS193p. Developing Applications for ios. Fall Stanford CS193p. Fall 2011

Announcements. Today s Topics

Assignment IV: Smashtag Mentions

Stanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017

Stanford CS193p. Developing Applications for ios. Winter CS193p. Winter 2017

Mobile Development Lab 3

Stanford CS193p. Developing Applications for ios. Fall CS193p. Fall

Step 1: Open Xcode and select Create a new Xcode Project from the Welcome to Xcode menu.

Xcode 4 Cookbook. Steven F. Daniel. Chapter No. 2 "User Interfaces Creating the UI"

Stanford CS193p. Developing Applications for ios. Spring CS193p. Spring 2016

Praktikum Entwicklung von Mediensystemen mit ios

ios 12 App Development Essentials

ios 11 App Development Essentials

Advanced ios. CSCI 4448/5448: Object-Oriented Analysis & Design Lecture 20 11/01/2012

ADVANCED M A. Learn SiriKit, imessage apps, rich notifications, and more. with real-world projects HACKING WITH SWIFT COMPLETE TUTORIAL COURSE

ITP 342 Mobile App Dev. Connections

Cocoa Touch Best Practices

Mastering UIKit on tvos

Building GUIs with UIKit. Kevin Cathey

ios DeCal : Lecture 2 Structure of ios Applications: MVC and Auto Layout

1 Build Your First App. The way to get started is to quit talking and begin doing. Walt Disney

Gerontechnology II. Collecting Smart Phone Sensor Data for Gerontechnology. Using ios

COMP327 Mobile Computing Session:

IPHONE DEVELOPMENT. Getting Started with the iphone SDK

CSC 581: Mobile App Development Spring 2018

Stichwortverzeichnis. 379, #define 287, 407 #import 50, 99 #pragma mark 415

Improving your Existing Apps with Swift

I, J. Key-value observing (KVO), Label component, 32 text property, 39

ios Core Data Example Application

Apple Watch Docs. Release 0.1. Michael Hahn

IOS - TEXT FIELD. Use of Text Field. Important Properties of Text Field. Updating Properties in xib

Q-1 What is Parsing? Explain XML parsing and JSON parsing with example. OR Explain JSON parsing with example.

Programming ios in Lua A bridge story

Learn to make desktop LE

LESSONS LEARNED. SWIFT. Dagna Bieda, 7th April 2016

Mobile Application Development

View Controller Lifecycle

Stream iphone Sensor Data to Adafruit IO

ErrorType protocol, 53

Tip Calculator App Introducing Swift, Text Fields, Sliders, Outlets, Actions, View Controllers, Event Handling, NSDecimalNumber,

Computer Science 251. iphone Application Development. Autorotation, Popover Controllers, Modal Controllers

Create an App that will drop PushPins onto a map based on addresses that the user inputs.

Designing iphone Applications

Transcription:

Tables Mobile Application Development in ios School of EECS Washington State University Instructor: Larry Holder Mobile Application Development in ios 1

Outline Table View Controller Table View Table Cells Cell interaction Navigation Mobile Application Development in ios 2

Table View Controller 2. Create Cocoa Touch Class inheriting from UITableViewController. 3. Assign new class to Table View Controller. 1. Add Table View Controller to Storyboard. Mobile Application Development in ios 3

Table View Attributes TableView Content: Static Multiple sections Fixed number of cells Design each cell individually Mobile Application Development in ios 4

Table View Attributes TableView Content: Dynamic One section Variable number of cells Design cell prototypes Mobile Application Development in ios 5

Table Cell Styles Table cell styles Basic Right detail Left detail Subtitle Custom Mobile Application Development in ios 6

Delegate and Data Source UITableViewDelegate protocol Configuring table Handling table interaction UITableViewDataSource Source for each row's data func tableview(_ tableview: UITableView, cellforrowat indexpath: IndexPath) -> UITableViewCell Handling insertion and deletion Mobile Application Development in ios 7

Delegate and Data Source Automatic connection for Table View Controller Mobile Application Development in ios 8

Custom Cells: Step 1 Create custom class extending UITableViewCell Initialize and configure defaults as needed class TripCell: UITableViewCell { override func awakefromnib() { super.awakefromnib() // Initialization code override func setselected(_ selected: Bool, animated: Bool) { super.setselected(selected, animated: animated) // Configure the view for the selected state Mobile Application Development in ios 9

Custom Cells: Step 2 Create custom table view prototype cell on Storyboard Set Identifier Set Custom Class to class from Step 1 Mobile Application Development in ios 10

Custom Cells: Step 3 Connect cell elements to cell class Mobile Application Development in ios 11

Custom Cells: Step 4 Configure cells in UITableViewController class TableViewController: UITableViewController { //... override func tableview(_ tableview: UITableView, cellforrowat indexpath: IndexPath) -> UITableViewCell { let cell = tableview.dequeuereusablecell(withidentifier: "tripcell", for: indexpath) as! TripCell cell.tripimage.image = UIImage(named: "kauai.jpg") cell.triplabel.text = "Kauai" return cell Mobile Application Development in ios 12

Navigation Embed in Navigation Controller Create views for Detail and Add Create segue to Detail View Perform when row/accessory selected From View, not row Create Add bar button Create segue from Add button to Add View Mobile Application Development in ios 13

Cell Interaction: Selection Row Selection override func tableview(_ tableview: UITableView, didselectrowat indexpath: IndexPath) { self.selectedrow = indexpath.row // retain for prepareforsegue performsegue(withidentifier: "todetail", sender: nil) Accessory Selection (only for Detail ) override func tableview(_ tableview: UITableView, accessorybuttontappedforrowwith indexpath: IndexPath) { self.selectedrow = indexpath.row // retain for prepareforsegue performsegue(withidentifier: "todetail", sender: nil) Mobile Application Development in ios 14

Cell Interaction: Deletion // Override to support conditional editing of the table view. override func tableview(_ tableview: UITableView, caneditrowat indexpath: IndexPath) -> Bool { // Return false if you do not want the specified item to be editable. return true // Override to support editing the table view. override func tableview(_ tableview: UITableView, commit editingstyle: UITableViewCellEditingStyle, forrowat indexpath: IndexPath) { if editingstyle ==.delete { // Delete the row from the data source first trips.remove(at: indexpath.row) tableview.deleterows(at: [indexpath], with:.fade) Mobile Application Development in ios 15

Insertion In AddViewController.swift Maintain Bool indicating new entry ready Save button sets Bool=true and performs unwind segue class AddViewController: UIViewController, UITextFieldDelegate { var newtripready: Bool = false @IBOutlet weak var nametextfield: UITextField! @IBAction func savetapped(_ sender: UIBarButtonItem) { newtripready = true performsegue(withidentifier: "unwindfromadd", sender: nil) //... Mobile Application Development in ios 16

Insertion (cont.) In TableViewController.swift In unwind segue Check if new entry ready If so, create new data instance, add to array, and reload data @IBAction func unwindfromadd (segue: UIStoryboardSegue) { let addvc = segue.source as! AddViewController if (addvc.newtripready) { let name = addvc.nametextfield.text! trips.append(name) self.tableview.reloaddata() Mobile Application Development in ios 17

Adding Table View to Existing View Set Delegate and Data Source Mobile Application Development in ios 18

Set Delegate and Data Source Programmatically Conform view controller to UITableViewDelegate and UITableViewDataSource protocols Create outlet connection to table view Set table view delegate and datasource to self class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource { @IBOutlet weak var triptable: UITableView! override func viewdidload() { super.viewdidload() // Do any additional setup after loading the view. triptable.delegate = self triptable.datasource = self Mobile Application Development in ios 19

Resources Start Developing ios Apps (good Tables tutorial) developer.apple.com/library/content/referencelibrary /GettingStarted/DevelopiOSAppsSwift UITableViewController (documentation) developer.apple.com/documentation/uikit/uitablevie wcontroller Mobile Application Development in ios 20