EEC-492/693/793 iPhone Application Development

Slides:



Advertisements
Similar presentations
© 2011 Delmar, Cengage Learning Chapter 1 Getting Started with Dreamweaver.
Advertisements

Database Basics. What is Access? Database management system Computer-based equivalent of a manual database Makes it easy to organize and update information.
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.
Working with Tables for Page Design – Lesson 41 Working with Tables for Page Design Lesson 4.
The Web Warrior Guide to Web Design Technologies
Chapter 18 - Data sources and datasets 1 Outline How to create a data source How to use a data source How to use Query Builder to build a simple query.
Introduction to Objective-C and Xcode (Part 1) FA 175 Intro to Mobile App Development.
Using Folders to Organize Files
© by Pearson Education, Inc. All Rights Reserved.
Chapter 3 Tables and Page Layout
Anatomy of an iPhone Application Content taken from book: “iPhone SDK Development” by Bill Dudney and Chris Adamson.
View Controllers (second part) Content taken from book: “iPhone SDK Development” by Bill Dudney and Chris Adamson.
IPhone Development Crash Course By Dylan Harris
IPhone 101. Outline Objective-C Random bits of the API Using the simulator Debugging with Xcode.
Storyboards Managing multiple views. Overview Create a single view application Give the project a name and click “Use Storyboards” and “Use Automatic.
Sprite Animation CSE 391 Fall 2012 Tony Scarlatos.
ACCESS CHAPTER 1. OBJECTIVES Tables Queries Forms Reports Primary and Foreign Keys Relationship.
Programming with Microsoft Visual Basic 2012 Chapter 13: Working with Access Databases and LINQ.
Tip Calculator App Building an Android App with Java © by Pearson Education, Inc. All Rights Reserved.
iOS components in Swift
CIS 205—Web Design & Development Dreamweaver Chapter 1.
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.
Domain 3 Understanding the Adobe Dreamweaver CS5 Interface.
Pasewark & Pasewark 1 Access Lesson 5 Creating and Modifying Reports Microsoft Office 2007: Introductory.
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.
Chapter 5 Quick Links Slide 2 Performance Objectives Understanding Framesets and Frames Creating Framesets and Frames Selecting Framesets and Frames Using.
© 2008 The McGraw-Hill Companies, Inc. All rights reserved. WORD 2007 M I C R O S O F T ® THE PROFESSIONAL APPROACH S E R I E S Lesson 15 Advanced Tables.
View Controllers Content taken from book: “iPhone SDK Development” by Bill Dudney and Chris Adamson.
Introduction to Objective-C and Xcode (Part 5) FA 175 Intro to Mobile App Development.
Sounds, Images, and Text FA 172 Intro to Mobile App Development.
Nav Controllers UINavigationController. Overview Nav Controller basics Like a tabview controller, a navViewController manages views A navigationViewController.
Pasewark & Pasewark 1 Access Lesson 5 Creating and Modifying Reports Microsoft Office 2007: Introductory.
LANDESK SOFTWARE CONFIDENTIAL Tips and Tricks with Filters Jenny Lardh.
HTML Basics. HTML Coding HTML Hypertext markup language The code used to create web pages.
Lecture 10 Using Interface Builder to create Mac Applications.
Introducing Dreamweaver. Dreamweaver The web development application used to create web pages Part of the Adobe creative suite.
Unit 3: Text, Fields & Tables DT2510: Advanced CAD Methods.
2/20/2016 EEC492/693/793 - iPhone Application Development 12/20/2016 EEC492/693/793 - iPhone Application Development 1 EEC-492/693/793 iPhone Application.
Dreamweaver MX. 2 Timeline Overview (p. 480) n Animations can be achieved with DHTML (__________ HTML) using JavaScript code and _____ or later browsers.
Lec 12 Pickers CS 3800 Introduction to IOS programming Lecture 12 Summer 2011.
Course Summary Xcode & iPhone Simulator
EEC-693/793 Applied Computer Vision with Depth Cameras
Weebly Elements, Continued
About the To-Do Bar in Outlook
EEC-693/793 Applied Computer Vision with Depth Cameras
CARA 3.10 Major New Features
How to design a Windows Forms application
Visual programming Chapter 1: Introduction
Getting Started with Dreamweaver
EEC-492/693/793 iPhone Application Development
EEC-693/793 Applied Computer Vision with Depth Cameras
EEC-492/693/793 iPhone Application Development
EEC-492/693/793 iPhone Application Development
EEC-492/693/793 iPhone Application Development
Word Lesson 7 Working with Documents
Delegating Access & Managing Another Person’s Mail/Calendar with Outlook Information Technology.
EEC-492/693/793 iPhone Application Development
DREAMWEAVER MX 2004 Chapter 3 Working with Tables
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
Using Templates and Library Items
EEC-492/693/793 iPhone Application Development
EEC-492/693/793 iPhone Application Development
EEC-693/793 Applied Computer Vision with Depth Cameras
Guidelines for Microsoft® Office 2013
EEC-492/693/793 iPhone Application Development
CSC 581: Mobile App Development
Presentation transcript:

EEC-492/693/793 iPhone Application Development Lecture 9 Wenbing Zhao & Nigamanth Sridhar 9/21/2018 EEC492/693/793 - iPhone Application Development

Outline Administrative Objective-C This Wed. 10/6: make-up session Students who have completed all assignments can omit it Oct 11 (next Monday), Columbus day, no class Objective-C @selector Tab bar based multiview applications Pickers Assignments: Build the Pickers app (chapter 7) Continue building the calculator app Objective-C part is shamelessly taken from Stanford CS193P winter 2010 lecture 3 9/21/2018 9/21/2018 EEC492/693/793 - iPhone Application Development EEC492/693/793 - iPhone Application Development 2

EEC492/693/793 - iPhone Application Development @selector @selector is somewhat similar to the function pointer in C, or more accurately, the dlsym() call It offers a mechanism for a developer to dynamically choose a method to invoke (or a message to send in OO language) @selector takes the name of a method (with all arguments stripped off) @selector returns a special type, SEL SEL setWidthHeight; setWidthHeight = @selector(setWidth:height:); // assuming we have a method: -(void)setWidth: (int)w height: (int)h 9/21/2018 EEC492/693/793 - iPhone Application Development

EEC492/693/793 - iPhone Application Development @selector You can call a method (or send a message) using @selector If you have a set of methods defined like these: - (void) doSomething: - (void) doSomething:(NSObject*)obj - (void) doSomething:(NSObject*)obj1 withObject:(NSNumber*)obj2 The selectors will be declared like these, respectively: @selector(doSomething:) @selector(doSoemthing:) //same as before @selector(doSomething:withObject:) To perform a selector on an object, you can use: [someObj performSelector:@selector(doSomething:)]; [someObj performSelector:@selector(doSomething:) withObject: o]; [someObj performSelector:@selector(doSomething:withObject:) withObject: o1, withObject: o2]; 9/21/2018 EEC492/693/793 - iPhone Application Development

EEC492/693/793 - iPhone Application Development @selector Want to check if an object will respond to a message obtained via a selector? -(BOOL)respondsToSelector:(SEL)aSelector if ( [anObject respondsToSelector:@selector(setOrigin::)] ) [anObject setOrigin:0.0 :0.0]; else fprintf(stderr, "%s can’t be placed\n", [NSStringFromClass([anObject class]) UTF8String]); Q: Why double colons in setOrigin:: ? 9/21/2018 EEC492/693/793 - iPhone Application Development

EEC492/693/793 - iPhone Application Development @selector @selector used in chapter 7 NSArray *sorted = [components sortedArrayUsingSelector:@selector(compare:)]; [self performSelector:@selector(showButton) withObject:nil afterDelay:1.5]; [self performSelector:@selector(playWinSound) withObject:nil afterDelay:.5]; 9/21/2018 EEC492/693/793 - iPhone Application Development

Tab Bar Based Multiview Applications Create needed individual view controllers and their nib files Modify the app delegate: Use UITabVarController as the root view controller Add an outlet to the root controller Add the root view as a subview to the main window [window addSubview:rootController.view]; Connect the outlet to the root controller Control-drag from the app delegate icon to the Tab Bar Controller icon, selecting the rootController outlet Tab Bar Controller View Controller 9/21/2018 EEC492/693/793 - iPhone Application Development

Tab Bar Based Multiview Applications In the IB, drag a Tab Bar Controller from the library to MainWindow.xib Modify the number of views needed in the attribute inspector of the tab var controller (use the + or – sign) Highlight each tab, link with nib file (⌘1), and specify to the proper controller class (⌘4) Click on the tab again to change the selection to the tab bar item. In the inspector, link with the image file, and change to the desirable title Implementing individual content views 9/21/2018 EEC492/693/793 - iPhone Application Development

EEC492/693/793 - iPhone Application Development Pickers A picker lets the user select an item from a list For the picker to work, you must provide it with both a picker delegate and a picker datasource The picker defers several jobs to its delegate Determine what to draw for each of the rows in each of its components The picker asks the delegate for either a string or a view that will be drawn at a given spot on a given component The picker also gets its data from the delegate The datasource tells the picker how many components it will be working with and how many rows make up each component For a simple picker, its view controller is usually used as the datasource and delegate 9/21/2018 EEC492/693/793 - iPhone Application Development

Pickers: Datasource and Delegate @interface SingleComponentPickerViewController : UIViewController <UIPickerViewDelegate, UIPickerViewDataSource> { UIPickerView *singlePicker; NSArray *pickerData; } #pragma mark - #pragma mark Picker Data Source Methods - (NSInteger)numberOfComponentsInPickerView:(UIPickerView *)pickerView { return 1;} - (NSInteger)pickerView:(UIPickerView *)pickerView numberOfRowsInComponent:(NSInteger)component { return [pickerData count]; } #pragma mark Picker Delegate Methods - (NSString *)pickerView:(UIPickerView *)pickerView titleForRow:(NSInteger)row forComponent:(NSInteger)component { return [pickerData objectAtIndex:row]; 9/21/2018 EEC492/693/793 - iPhone Application Development

Pickers: More Delegate Methods The content of one component might have to be updated if a row has been selected in a different component (void)pickerView:(UIPickerView *)pickerView didSelectRow:(NSInteger)row inComponent:(NSInteger)component { if (component == kStateComponent) { NSString *selectedState = [self.states objectAtIndex:row]; NSArray *array = [stateZips objectForKey:selectedState]; self.zips = array; // swap zips array whenever the state changes // set the right-hand component back to the 1st row [picker selectRow:0 inComponent:kZipComponent animated:YES]; // tell it to reload itself [picker reloadComponent:kZipComponent]; } 9/21/2018 EEC492/693/793 - iPhone Application Development

Pickers: More Delegate Methods The width of each component in a picker can be adjusted by implementing a delegate method - (CGFloat)pickerView:(UIPickerView *)pickerView widthForComponent:(NSInteger)component { if (component == kZipComponent) return 90; return 200; } 9/21/2018 EEC492/693/793 - iPhone Application Development

EEC492/693/793 - iPhone Application Development NSBundle A bundle is a special type of folder whose contents follow a specific structure Applications and frameworks are both bundles A primary use of NSBundle is to get to resources that added to the Resources folder of the project If we want to get to those resources in our code, we usually have to use NSBundle NSBundle *bundle = [NSBundle mainBundle]; // this will return a string containing the location of the statedictionary.plist file NSString *plistPath = [bundle pathForResource:@"statedictionary" ofType:@"plist"]; // use the plist NSDictionary *dictionary = [[NSDictionary alloc] initWithContentsOfFile:plistPath]; 9/21/2018 EEC492/693/793 - iPhone Application Development

UIImage and UIImageView How to create a UIImageView // by using a convenience method on the UIImage class, we don’t have to // first determine the location of each image and then use that info to // load the image UIImage *seven = [UIImage imageNamed:@"seven.png"]; UIImageView *sevenView = [[UIImageView alloc] initWithImage:seven]; 9/21/2018 EEC492/693/793 - iPhone Application Development

More Methods on Property Set a property based on its name (mutator) setValue:forKey: [self setValue:imageViewArray forKey:fieldName]; // If fieldName is column1, and we have a property called // column1, it is equivalent to: [self setColumn1 imageViewArray) Get the value of a property based on its name (accessor) valueForKey: NSArray *array = [self valueForKey:arrayName]; 9/21/2018 EEC492/693/793 - iPhone Application Development

Adding Sounds to Your App Import header file: #import <AudioToolbox/AudioToolbox.h> Getting the path to the sound file NSString *path = [[NSBundle mainBundle] pathForResource:@"win“ ofType:@"wav"]; Create sound ID SystemSoundID soundID; AudioServicesCreateSystemSoundID((CFURLRef)[NSURL fileURLWithPath:path], &soundID); Play the sound AudioServicesPlaySystemSound (soundID); You must manually link with the AudioToolBox.framework Make sure select a Reference Type of Relative to Current SDK 9/21/2018 EEC492/693/793 - iPhone Application Development