EEC-492/693/793 iPhone Application Development

Slides:



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

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.
Wednesday 2-3:30, DH 1046 COMP 446 / ELEC 446 Mobile Device Applications Scott Cutler Professor in the Practice of Computer Technology Department of Computer.
TableView and TableViewController
Project Implementation for COSC 5050 Distributed Database Applications Lab4.
The Problem: iPhone UI Navigation I want to have a TableView that works INSIDE a TabView.
Storyboards Managing multiple views. Overview Create a single view application Give the project a name and click “Use Storyboards” and “Use Automatic.
ACCESS CHAPTER 1. OBJECTIVES Tables Queries Forms Reports Primary and Foreign Keys Relationship.
Creating a Web Site to Gather Data and Conduct Research.
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
1 Data Bound Controls II Chapter Objectives You will be able to Use a Data Source control to get data from a SQL database and make it available.
1 Designing with a UIToolBar iPhone/iPad, iOS Development Tutorial.
S511 Session 7, IU-SLIS 1 DB Implementation: MS Access Forms.
Navigation in iPads splitViewController. Overview Create a Master-Detail application Switch Device Family to iPad Give the project a name and click “Use.
Chapter 5 Quick Links Slide 2 Performance Objectives Understanding Framesets and Frames Creating Framesets and Frames Selecting Framesets and Frames Using.
View Controllers Content taken from book: “iPhone SDK Development” by Bill Dudney and Chris Adamson.
Course Summary Xcode & iPhone Simulator
Nav Controllers UINavigationController. Overview Nav Controller basics Like a tabview controller, a navViewController manages views A navigationViewController.
TRAINING SESSIONS.NET Controls.  Standard Controls  Label  Textbox  Checkbox  Button, Image Button, Image control  Radio Button  Literal  Hyperlink.
Reference: “ASP.NET 2.0 Illustrated” by Alex Homer and Dave Sussman. -ch3 illustrated book
User Interface Objects From Beginning iPhone 4 Development and The iPhone Developer’s Cookbook (Chapter 4)
Table Views UITableView.
XPages Example: Generating Dynamic Editable Fields from a Document Collection Author: John Mackey Groupware Solutions Inc.
XP New Perspectives on Macromedia Dreamweaver MX 2004 Tutorial 5 1 Adding Shared Site Elements.
1 디바이스 정보  UIDevice 클래스가 제공하고 static 메서드인 currentDevice 가 객체를 생성합 니다.  제공하는 정보 uniqueIdentifier: 장치 고유 ID / 회원가입을 하지 않고 어플을 운영 가능 model: 모델명 systemVersion:
LEARN TO FORMAT TABLES Unit 10: Lessons What is a Table? ◦ A table is an arrangement of data (words and/or numbers) in rows and columns. ◦ A table.
DB Implementation: MS Access Forms. MS Access Forms: Purpose Data entry, editing, & viewing data in Tables Forms are user-friendlier to end-users than.
수업 진행 UINavigationController ( 목 ) Animation ( 목 ) TabBarViewController ( 목 ) UITableViewController ( 금 ) CoreLocation ( 토 )
CHAPTER 7 LESSON B Creating Database Reports. Lesson B Objectives  Describe the components of a report  Modify report components  Modify the format.
Course Summary Xcode & iPhone Simulator
Views in iOS Mobile apps for iPhone & iPad Telerik Software Academy
Working in the Forms Developer Environment
iOS UI Components Sisoft Technologies Pvt Ltd
2 At the top of the zone in which you want to add the Web Part, click Add a Web Part. In the Add Web Parts to [zone] dialog box, select the check box of.
Practical Office 2007 Chapter 10
Building a User Interface with Forms
2 At the top of the zone in which you want to add the Web Part, click Add a Web Part. In the Add Web Parts to [zone] dialog box, select the check box of.
Play Framework: Introduction
Introduction to Triggers
Core LIMS Training: Advanced Administration
Developing an Excel Application
Programming the Web using XHTML and JavaScript
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.
View-Controller Family
Chap 7. Building Java Graphical User Interfaces
FTS 2 (Failure Tracking System) System Test Process Flow
EEC-492/693/793 iPhone Application Development
EEC-492/693/793 iPhone Application Development
EEC-492/693/793 iPhone Application Development
DB Implementation: MS Access Forms
Graphical User Interfaces -- Introduction
Unit I: Developing Multipage Documents
EEC-492/693/793 iPhone Application Development
MODULE 7 Microsoft Access 2010
Chapter 2 – Introduction to the Visual Studio .NET IDE
A lighting tour™ to iOS Plus some fun stuff
Tutorial 6 Creating Dynamic Pages
Benchmark Series Microsoft Word 2016 Level 2
DB Implementation: MS Access Forms
Working with Symbols and Interactivity
EEC-492/693/793 iPhone Application Development
EEC-492/693/793 iPhone Application Development
EEC-492/693/793 iPhone Application Development
EEC-492/693/793 iPhone Application Development
Netscape Composer Add A Custom Button.
EEC-492/693/793 iPhone Application Development
Creating Additional Input Items
Lesson 13 Working with Tables
Presentation transcript:

EEC-492/693/793 iPhone Application Development Lecture 12 Wenbing Zhao & Nigamanth Sridhar 4/9/2019 EEC492/693/793 - iPhone Application Development

Outline More on table views Using table view & navigation controller together Assignments: The push and pop app Continue building the calculator app 4/9/2019 4/9/2019 EEC492/693/793 - iPhone Application Development EEC492/693/793 - iPhone Application Development 2

EEC492/693/793 - iPhone Application Development More on Table Views UITableView Data Source UITableView Delegate UITableViewController UITableViewCell 4/9/2019 EEC492/693/793 - iPhone Application Development

Basic UITableViewDataSource Methods Provide number of sections and rows // Optional method, defaults to 1 if not implemented - (NSInteger)numberOfSectionsInTableView:(UITableView *)table; // Required method - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section; Provide cells for table view as needed - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath; 4/9/2019 EEC492/693/793 - iPhone Application Development

Datasource Message Flow numberOfSectionsInTableView: How many Sections? Datasource 5 4/9/2019 EEC492/693/793 - iPhone Application Development

Datasource Message Flow tableView:numberOfRowsInSection: 1 How many rows In section 0? Datasource 4/9/2019 EEC492/693/793 - iPhone Application Development

Datasource Message Flow tableView:cellForRowAtIndexPath: Cell with text “John Appleseed” What to display at section 0, row 0? Datasource 4/9/2019 EEC492/693/793 - iPhone Application Development

NSIndexPath and Table Views Cell location described with an index path Section index + row index Category on NSIndexPath with helper methods @interface NSIndexPath (UITableView) + (NSIndexPath *)indexPathForRow:(NSUInteger)row inSection:(NSUInteger)section; @property(nonatomic,readonly) NSUInteger section; @property(nonatomic,readonly) NSUInteger row; @end 4/9/2019 EEC492/693/793 - iPhone Application Development

Single Section Table View Return the number of rows - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [myStrings count]; } Provide a cell when requested - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath UITableViewCell *cell = ...; cell.textLabel.text = [myStrings objectAtIndex:indexPath.row] return [cell autorelease]; 4/9/2019 EEC492/693/793 - iPhone Application Development

EEC492/693/793 - iPhone Application Development Cell Reuse When asked for a cell, reuse one if possible - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@“MyIdentifier”]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:... reuseIdentifier:@“MyIdenifier”] autorelease]; } cell.text = [myStrings objectAtIndex:indexPath.row] return cell; 4/9/2019 EEC492/693/793 - iPhone Application Development

EEC492/693/793 - iPhone Application Development Triggering Updates When is the datasource asked for its data? When a row becomes visible When an update is explicitly requested by calling -reloadData - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self.tableView reloadData]; } 4/9/2019 EEC492/693/793 - iPhone Application Development

Section and Row Reloading (and Insertion and Deletion) Section reloading - (void)reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation; Row reloading - (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths Insert/delete - (void)insertSections:(NSIndexSet *)sections - (void)deleteSections:(NSIndexSet *)sections - (void)insertRowsAtIndexPaths:(NSArray *)indexPaths - (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths 4/9/2019 EEC492/693/793 - iPhone Application Development

Allow Editing and Reordering Cells Enable editing: Call self.tableView setEditing:YES Or use the system provided editButtonItem Allow deleting cells Implement data source method: - (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath { NSUInteger row = [indexPath row]; [self.list removeObjectAtIndex:row]; [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade]; } 4/9/2019 EEC492/693/793 - iPhone Application Development

Allow Editing and Reordering Cells Allow reordering cells - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath { return YES; } - (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath // update data in the model accordingly … 4/9/2019 EEC492/693/793 - iPhone Application Development

Disallowing Editing/Reordering Disallowing deleting - (UITableViewCellEditingStyle)tableView:(UITableView *)tableView editingStyleForRowAtIndexPath:(NSIndexPath *)indexPath { return UITableViewCellEditingStyleNone; } Disallowing reordering - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath return NO; 4/9/2019 EEC492/693/793 - iPhone Application Development

UITableView Delegate: Controlling Table View Appearance & Behavior Customize appearance of table view cell - (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath; Validate and respond to selection changes - (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath; didSelectRowAtIndexPath:(NSIndexPath *)indexPath; 4/9/2019 EEC492/693/793 - iPhone Application Development

Responding to Selection // For a navigation hierarchy... - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // Get the row and the object it represents NSUInteger row = indexPath.row id objectToDisplay = [myObjects objectAtIndex:row]; // Create a new view controller and pass it along MyViewController *myViewController = ...; myViewController.object = objectToDisplay; [self.navigationController pushViewController:myViewController animated:YES]; } 4/9/2019 EEC492/693/793 - iPhone Application Development

Altering or Disabling Selection - (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath { // Don’t allow selecting certain rows? if (indexPath.row == ...) { return nil; } else { return indexPath; } 4/9/2019 EEC492/693/793 - iPhone Application Development

UITableViewController Convenient starting point for view controller with a table view Table view is automatically created Controller is table view’s delegate and datasource Takes care of some default behaviors Calls -reloadData the first time it appears Deselects rows when user navigates back Flashes scroll indicators 4/9/2019 EEC492/693/793 - iPhone Application Development

EEC492/693/793 - iPhone Application Development Table View Cells Initializer - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier; Cell Styles UITableViewCellStyleDefault, UITableViewCellStyleSubtitle, UITableViewCellStyleValue1, UITableViewCellStyleValue2 Basic properties UITableViewCell has an image view and one or two text labels cell.imageView.image = [UIImage imageNamed:@“vitolidol.png”]; cell.textLabel.text = @“Vitol Idol”; cell.detailTextLabel.text = @“Billy Idol”; 4/9/2019 EEC492/693/793 - iPhone Application Development

Table View Cell Accessory Types // UITableView delegate method - (UITableViewCellAccessoryType)tableView:(UITableView *)table accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath; - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath { // Only for the blue disclosure button NSUInteger row = indexPath.row; ... } UITableViewCellAccessoryDisclosureIndicator UITableViewCellAccessoryDetailDisclosureButton UITableViewCellAccessoryCheckmark 4/9/2019 EEC492/693/793 - iPhone Application Development

Customizing the Content View For cases where a simple image + text cell doesn’t suffice UITableViewCell has a content view property Add additional views to the content view - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell = ...; CGRect frame = cell.contentView.bounds; UILabel *myLabel = [[UILabel alloc] initWithFrame:frame]; myLabel.text = ...; [cell.contentView addSubview:myLabel]; [myLabel release]; } 4/9/2019 EEC492/693/793 - iPhone Application Development

Using Table View and Navigation Controller Together Pushing a TableViewController as the first view controller on the navigation stack - (void)applicationDidFinishLaunching:(UIApplication *)application { UINavigationController *navController = [[UINavigationController alloc] init]; FirstLevelViewController *viewController = [[FirstLevelViewController alloc] init]; [navController pushViewController:viewController animated:NO]; [viewController release]; [window addSubview:navController.view]; [window makeKeyAndVisible]; } Do Not Follow the Book on This Step 4/9/2019 EEC492/693/793 - iPhone Application Development

Push Another View Controller on the Stack due to User Actions - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath { childController = [[DisclosureDetailController alloc] initWithNibName:@"DisclosureDetail" bundle:nil]; … [self.navigationController pushViewController:childController animated:YES]; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { PresidentDetailController *childController = [[PresidentDetailController alloc] initWithStyle:UITableViewStyleGrouped]; …. [self.navigationController pushViewController:childController animated:YES]; } 4/9/2019 EEC492/693/793 - iPhone Application Development

Pop a View Controller from the Stack Tag the back button When handling user action -(IBAction)cancel:(id)sender{ [self.navigationController popViewControllerAnimated:YES]; } 4/9/2019 EEC492/693/793 - iPhone Application Development

EEC492/693/793 - iPhone Application Development Assignment Build the Nav app Please use the better way to push the first table view controller on the stack Challenge In the current Nav app, the PresentsView is NOT updated after you have modified a President’s info (in the PresidentDetail view) Fix this! 4/9/2019 EEC492/693/793 - iPhone Application Development