Table Views UITableView. Overview Table view basics Tables display lists of data Each item in a tables list is a row Tables can have an unlimited number.

Slides:



Advertisements
Similar presentations
Integrating Facebook into iOS Apps 08/25/2011 North Atlanta iOS Developers Meetup Group Presentation.
Advertisements

MS® PowerPoint.
Working with Intrinsic Controls and ActiveX Controls
1. Chapter 29 Creating Forms 3 Understanding Forms Word enables you to create fill-in forms to eliminate the need for storing pre-printed forms. Add.
TableView and TableViewController
Dh 1 Million Dh 500,000 Dh 250,000 Dh 125,000 Dh 64,000 Dh 32,000 Dh 16,000 Dh 8,000 Dh 4,000 Dh 2,000 Dh 1,000 Dh 500 Dh 400 Dh 300 Dh 200 Dh 100.
The Problem: iPhone UI Navigation I want to have a TableView that works INSIDE a TabView.
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
View Controllers (second part) Content taken from book: “iPhone SDK Development” by Bill Dudney and Chris Adamson.
Macros Tutorial Week 20. Objectives By the end of this tutorial you should understand how to: Create macros Assign macros to events Associate macros with.
1 of 5 This document is for informational purposes only. MICROSOFT MAKES NO WARRANTIES, EXPRESS OR IMPLIED, IN THIS DOCUMENT. © 2007 Microsoft Corporation.
Storyboards Managing multiple views. Overview Create a single view application Give the project a name and click “Use Storyboards” and “Use Automatic.
1 Agenda Overview Review Roles Lists Libraries Columns.
Access Tutorial 10 Automating Tasks with Macros
8 Copyright © 2004, Oracle. All rights reserved. Creating LOVs and Editors.
Sprite Animation CSE 391 Fall 2012 Tony Scarlatos.
Refactoring Moving a console app to a UI app. Refactoring Goal: change a console app to a UI app Principles: The main.m goes away The local variables.
Xcode Presentation Tom Pletzke. Creating App from template Launch Xcode Select Tabbed Application.
Microsoft Excel 2000 Adding Visual Elements and Managing Files.
Xcode testing Using XCTest.
Project 9 Using Visual Basic for Applications (VBA) to Customize and Automate Excel Jason C. H. Chen, Ph.D. Professor of Management Information Systems.
1 1 iOS - iPhone/iPad Application Development Workshop Part 1.
Chapter 12 Working with Text. Text Field Types Static text – used to display information or to label buttons, forms, or navigation. Dynamic text – used.
Adding Content to the Agency Web Site - Part 2. Adding individual web pages for success stories Agency Web Site Adding Content 2, Slide 2Copyright © 2004,
iOS components in Swift
Chapter 10 Fireworks: Part II The Web Warrior Guide to Web Design Technologies.
Macromedia Dreamweaver 8-- Illustrated Introductory 1 Macromedia Dreamweaver 8 Unit D Formatting Text and Using Cascading Style Sheets.
1 Designing with a UIToolBar iPhone/iPad, iOS Development Tutorial.
Excel CREATING A WORKSHEET AND CHART. Personal Budget Worksheet We will create a personal budget worksheet that shows you income each month and your expenses.
Tabbed Views UITabBarController. Controller Architecture UITabBarController Controls the first view that the user sees The view controller class (and.
Navigation in iPads splitViewController. Overview Create a Master-Detail application Switch Device Family to iPad Give the project a name and click “Use.
Office Management Tools II Ms Saima Gul. Office Management Tools II Ms Saima Gul.
IOS with Swift Hello world app.
Managing Multiple Views and Segues FA 172 Intro to Mobile App Development.
View Controllers Content taken from book: “iPhone SDK Development” by Bill Dudney and Chris Adamson.
Learning How to Make a PowerPoint Presentation A tutorial for novice users.
Copyright 2007, Paradigm Publishing Inc. ACCESS 2007 Chapter 3 BACKNEXTEND 3-1 LINKS TO OBJECTIVES Modify a Table – Add, Delete, Move Fields Modify a Table.
Gestures UIGestureRecognizer.
Course Summary Xcode & iPhone Simulator
Nav Controllers UINavigationController. Overview Nav Controller basics Like a tabview controller, a navViewController manages views A navigationViewController.
Microsoft Excel 2000 Analyzing Data Using Excel. ©2001 Paradigm Publishing Inc.Excel Section Title Bar Menu Bar Formatting Toolbar Standard Toolbar.
Table Views UITableView.
 2002 Prentice Hall. All rights reserved. 1 Chapter 2 – Introduction to the Visual Studio.NET IDE Outline 2.1Introduction 2.2Visual Studio.NET Integrated.
Ribbon-ology Funky Fonts Paragraph Perfection Add ThisOptions.
1 UI Alert View iPhone/iPad, iOS Development Tutorial.
CMPF114 Computer Literacy Chapter 3 The Visual Basic Environment 1.
The iOS Platform and SDK. iOS iPhoneiPad Mini iPad.
Video in Macromedia Flash (Optional) – Lesson 121 Video in Macromedia Flash (Optional) Lesson 12.
Transportation Agenda 187. Transportation About Web Parts Web parts are reusable “containers” that reside on web pages and interact with lists, libraries.
Progress and Outcome Measures - Part 3 Progress and Outcome Measures Part 3, Slide 1Copyright © 2004, Jim Schwab, University of Texas at Austin.
Microsoft PowerPoint Prepared by the Academic Faculty Members of IT.
Introduction to Objective-C and Xcode (Part 4) FA 175 Intro to Mobile App Development.
PowerPoint Chapter 1 Creating and Editing a Presentation with Clip Art Discovering Computers & Microsoft Office 2010.
Hamilton Software Products The Measure of Excellence Customized dialog.
WebViews UIWebView. Controller Architecture UITabBarController Controls the first view that the user sees The view controller class (and xib) that manages.
Lec 12 Pickers CS 3800 Introduction to IOS programming Lecture 12 Summer 2011.
Course Summary Xcode & iPhone Simulator
Views in iOS Mobile apps for iPhone & iPad Telerik Software Academy
Chapter A - Getting Started with Dreamweaver MX 2004
Core LIMS Training: Advanced Administration
UITableView API A table view is an instance of the UITableView class. Created given... an area on the screen, and A table style. Rows are created using.
EEC-492/693/793 iPhone Application Development
EEC-492/693/793 iPhone Application Development
EEC-492/693/793 iPhone Application Development
Chapter 2 – Introduction to the Visual Studio .NET IDE
Benchmark Series Microsoft Word 2016 Level 2
CSC 581: Mobile App Development
CSC 581: Mobile App Development
EEC-492/693/793 iPhone Application Development
EEC-492/693/793 iPhone Application Development
Presentation transcript:

Table Views UITableView

Overview Table view basics Tables display lists of data Each item in a tables list is a row Tables can have an unlimited number of rows Tables can only be one column wide (but see later slides) Reference: Apple Developer Reference

Views vs Cells A table view is a subclass of a view Technically it is a UITableView Each visible row in a table is an instance of a UITableViewCell Table view Table view cell

Table Data Table views do not store all the data Rather they just store data for the rows that are displayed They get their configuration data from the object that conforms to the UITabeViewdelegate protocol They get their row data from the object that conforms to the UITableViewDataSource protocol

Table Cells Each row is represented by a single UITableViewCell Each UITableViewCell object can be configured with an image, some text, an optional accessory icon If you need more data (or columns) in a cell you can create a subview Can do this programmatically Can do this in IB

Grouped Tables Plain Tables. The default style. May be indexed Grouped Tables. Each group is a set of rows embedded in a rounded rectangle. Can consist of a single group Each division in a table is known to your data source as a section In a grouped table, each group is a section In an indexed table, each indexed grouping of data is a section. E.g., names beginning with A, names beginning with B, etc.

Indexed vs Grouped Indexed TableGrouped Table

The app Well create a simple app with a single table view Later will create a navigation app that uses tables

Creating Create a new project Select single view application Choose a name, etc. Leave unchecked: include unit tests, use storyboards Check use automatic reference counting Choose a place to save Do not need to use git

What did you get? Look at the file navigator Normal appDelegate, viewcontroller, and nib

Creating the view Click on the nib to show IB Find a Table View in the library and drag to the view. The table view should automatically size itself to fill the entire view. Click on the view, bring up the connections inspector Under the outlets section drag from dataSource to Files Owner in the dock Under the outlets section drag from delegate to Files Owner in the dock This makes the viewController both the data source and delegate for the table.

Creating the controller in the Project Navigator click on the xxxViewController.h file and add the CMPViewController : (copy, nonatomic) NSArray This makes the view controller both the data source and the delegate of a table. The array will hold our data. Normally the data will reside in the model class not the controller class.

Creating the controller II in the Project Navigator click on the xxxViewController.m file and add the bold: #import BIDViewController (void)viewDidLoad { [super viewDidLoad]; @"Bifur", } The array will hold our table data

Creating the controller II in the Project Navigator click on the xxxViewController.m file and add the bold: (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [self.dwarves count]; } This method is called by the table when it needs to know how many rows are in the section (number of sections is 1 by default) We need as many rows as we have array entries.

Creating the controller II in the Project Navigator click on the xxxViewController.m file and add the bold: (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *SimpleTableIdentifier This method is called by the table when it needs a cell to display. We must return a UITableViewCell We identify the cells so that they can be reused later. Method continued on next slide….

Creating the controller II in the Project Navigator click on the xxxViewController.m file and add the bold: UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: SimpleTableIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SimpleTableIdentifier]; } cell.textLabel.text = self.dwarves[indexPath.row]; return cell; We check to see if there is an unused cell of the correct type that we can reuse. We return this cell; it will be displayed as the next row If there was no leftover cell we have to create a new one. The label text is what shows up in the row. As table rows scroll out of view, they are placed into a queue of cells to be reused. If memory gets low, they are discarded. The indexPath variable contains the row (and section) number that the table will use this cell for. Use default style; there are others!

Run! Should see a table. But cant select anything yet!

More on Cells Add image Add icon image to Xcode (size 40x40, 80x80 for retina) (see Lectures >Programming >star.png) Change the method below (assuming icon has name star.png) UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: SimpleTableIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:SimpleTableIdentifier]; } UIImage *image = [UIImage cell.imageView.image = image; cell.textLabel.text = self.dwarves[indexPath.row]; return cell; }

More on Cells Add detail text Cells can have additional (detail) text. There are different cell types also. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: SimpleTableIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:SimpleTableIdentifier]; } UIImage *image = [UIImage cell.imageView.image = image; if (indexPath.row < 7) { cell.detailTextLabel.text Disney"; } else { cell.detailTextLabel.text Tolkien"; } cell.textLabel.text = self.dwarves[indexPath.row]; return cell; } Must change the style of the cell for the subtitle to show up! Well use different subtitles for the first 7 rows (0-6). Subtitle Other styles: initWithStyle:UITableViewCellStyleValue1 initWithStyle:UITableViewCellStyleValue2

Detecting Row Selection Two events you can detect: When a row will be selected. Can prevent or change the selection When a row has been selected. Can react to the selection.

Detecting Row Selection When a row will be selected. Can prevent or change the selection Add to viewController.m: (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath { if (indexPath.row == 0) { return nil; } else { return indexPath; } Prevents row 0 from being selected.

Detecting Row Selection When a row has been selected. Put up alert box: Add to viewController.m: (void)tableView:(UITableView *)tableViewdidSelectRowAtIndexPath:(NSIndexPath *)indexPath { NSString *rowValue = self.dwarves[indexPath.row]; NSString *message = [[NSString alloc] selected rowValue]; UIAlertView *alert = [[UIAlertView alloc] Selected!" message:message delegate:nil I Did" otherButtonTitles:nil]; [alert show]; [tableView deselectRowAtIndexPath:indexPath animated:YES]; } Now deselect the row A typical alert box Find the name of the dwarf for the selected row

Other modifications to cells See Beginning iOS 6 Development chapter 8 Set indent level of row Set font size, row height Customize table view cells Programmatically Using a nib file Add groups Add indexes Add navigation bar or search bar Detail disclosure buttons (chapter 9)