52
iOS Training Part 2 Sam Kirchmeier [email protected] @skirchmeier Tuesday, March 20, 2012

Beginning i os part 2 sam kirchmeier

Embed Size (px)

DESCRIPTION

Mobile March 2012

Citation preview

Page 1: Beginning i os part 2   sam kirchmeier

iOS TrainingPart 2

Sam [email protected]

@skirchmeier

Tuesday, March 20, 2012

Page 4: Beginning i os part 2   sam kirchmeier

Topics

•Storyboards

•Navigation Controllers

•Table View Controllers

Tuesday, March 20, 2012

Page 5: Beginning i os part 2   sam kirchmeier

Goals

1. Display a list of tomorrow’s sessions

2. Display a live Twitter feed

3. Bask in the glory of our iOS prowess

Tuesday, March 20, 2012

Page 6: Beginning i os part 2   sam kirchmeier

Storyboards

Tuesday, March 20, 2012

Page 7: Beginning i os part 2   sam kirchmeier

ScenesView Controllers

SeguesTransitions

Tuesday, March 20, 2012

Page 8: Beginning i os part 2   sam kirchmeier

Tuesday, March 20, 2012

Page 9: Beginning i os part 2   sam kirchmeier

Scene

Tuesday, March 20, 2012

Page 10: Beginning i os part 2   sam kirchmeier

Scene

Segue

Tuesday, March 20, 2012

Page 11: Beginning i os part 2   sam kirchmeier

Segues- (IBAction)showAboutView:(id)sender{ // Use presentModalViewController to // display the view controller.}

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{ // Grab a reference to the view controller via // [segue destinationViewController].}

Old Way

New Way

Tuesday, March 20, 2012

Page 12: Beginning i os part 2   sam kirchmeier

Demo

Tuesday, March 20, 2012

Page 13: Beginning i os part 2   sam kirchmeier

Goal #1Display a list of sessions

Tuesday, March 20, 2012

Page 14: Beginning i os part 2   sam kirchmeier

Navigation Controller

Tuesday, March 20, 2012

Page 15: Beginning i os part 2   sam kirchmeier

Tuesday, March 20, 2012

Page 16: Beginning i os part 2   sam kirchmeier

Tuesday, March 20, 2012

Page 17: Beginning i os part 2   sam kirchmeier

View Controller 1 View Controller 2

Tuesday, March 20, 2012

Page 18: Beginning i os part 2   sam kirchmeier

Demo

Tuesday, March 20, 2012

Page 19: Beginning i os part 2   sam kirchmeier

Table View Controller

Tuesday, March 20, 2012

Page 20: Beginning i os part 2   sam kirchmeier

Tuesday, March 20, 2012

Page 21: Beginning i os part 2   sam kirchmeier

Tuesday, March 20, 2012

Page 22: Beginning i os part 2   sam kirchmeier

Navigation Controller

Tuesday, March 20, 2012

Page 23: Beginning i os part 2   sam kirchmeier

Navigation Controller

View Controller

Tuesday, March 20, 2012

Page 24: Beginning i os part 2   sam kirchmeier

Navigation Controller

View Controller

Table View

Tuesday, March 20, 2012

Page 25: Beginning i os part 2   sam kirchmeier

Navigation Controller

View Controller

Table View

Navigation Controller

Table View Controller

Table ViewBuilt In

Tuesday, March 20, 2012

Page 26: Beginning i os part 2   sam kirchmeier

Navigation Controller

View Controller

Table View

Tuesday, March 20, 2012

Page 27: Beginning i os part 2   sam kirchmeier

Navigation Controller

View Controller

Table View

Delegate

Data Source

Tuesday, March 20, 2012

Page 28: Beginning i os part 2   sam kirchmeier

Navigation Controller

View Controller

Table View

Delegate

Data SourceData Source Object

Number of rowsNumber of sections

Data to display in each row

Tuesday, March 20, 2012

Page 29: Beginning i os part 2   sam kirchmeier

Navigation Controller

View Controller

Table View

Delegate ObjectHandle touch events

Header and footer viewsRearrange rows

Delegate

Data SourceData Source Object

Number of rowsNumber of sections

Data to display in each row

Tuesday, March 20, 2012

Page 30: Beginning i os part 2   sam kirchmeier

Navigation Controller

View Controller

Table View

Delegate ObjectHandle touch events

Header and footer viewsRearrange rows

Delegate

Data SourceData Source Object

Number of rowsNumber of sections

Data to display in each row

UITableViewDataSource

UITableViewDelegate

Tuesday, March 20, 2012

Page 31: Beginning i os part 2   sam kirchmeier

Navigation Controller

Table View Controller

Table ViewBuilt In

Tuesday, March 20, 2012

Page 32: Beginning i os part 2   sam kirchmeier

Navigation Controller

Table View Controller

Table ViewBuilt In

Data Source

Delegate

Tuesday, March 20, 2012

Page 33: Beginning i os part 2   sam kirchmeier

UITableViewDataSource- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ // Return the number of rows here.}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

// Configure the cell here. return cell;}

Tuesday, March 20, 2012

Page 34: Beginning i os part 2   sam kirchmeier

UITableViewDelegate– tableView:didSelectRowAtIndexPath:

– tableView:heightForRowAtIndexPath:

– tableView:viewForHeaderInSection:

– tableView:viewForFooterInSection:

(and lots more)

Tuesday, March 20, 2012

Page 35: Beginning i os part 2   sam kirchmeier

UITableViewCell

Tuesday, March 20, 2012

Page 36: Beginning i os part 2   sam kirchmeier

Basic

Tuesday, March 20, 2012

Page 37: Beginning i os part 2   sam kirchmeier

Right Detail

Tuesday, March 20, 2012

Page 38: Beginning i os part 2   sam kirchmeier

Left Detail

Tuesday, March 20, 2012

Page 39: Beginning i os part 2   sam kirchmeier

Subtitle

Tuesday, March 20, 2012

Page 40: Beginning i os part 2   sam kirchmeier

Demo

Tuesday, March 20, 2012

Page 41: Beginning i os part 2   sam kirchmeier

Goal #2Display a Twitter feed

Tuesday, March 20, 2012

Page 42: Beginning i os part 2   sam kirchmeier

Twitter Framework

Tuesday, March 20, 2012

Page 43: Beginning i os part 2   sam kirchmeier

TWRequestTWRequest *request = [[TWRequest alloc] initWithURL:URL parameters:parameters requestMethod:TWRequestMethodGET];

[request performRequestWithHandler:^( NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error){ // Invoked after the response is complete. // Parse response and display tweets.}];

Tuesday, March 20, 2012

Page 44: Beginning i os part 2   sam kirchmeier

^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error){ // Invoked after the response is complete. // Parse response and display tweets.}

Request Handler Block

[request performRequestWithHandler: ];Request Handler Block

Tuesday, March 20, 2012

Page 45: Beginning i os part 2   sam kirchmeier

Threads[request performRequestWithHandler: ];Request Handler Block

This handler is not guaranteed to be called on any particular

thread.

Apple

Tuesday, March 20, 2012

Page 46: Beginning i os part 2   sam kirchmeier

Danger^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error){ // Parse the Twitter response. ...

// Assign an array of tweets to our tweets property. ...

// Reload the table view. // This might not work! [self.tableView reloadData];}

Request Handler Block

Tuesday, March 20, 2012

Page 47: Beginning i os part 2   sam kirchmeier

OK^(NSData *responseData, NSHTTPURLResponse *urlResponse, NSError *error){ // Parse the Twitter response. ...

// Assign an array of tweets to our tweets property. ...

// Reload the table view. This will work! [self.tableView performSelectorOnMainThread:@selector(reloadData) withObject:nil waitUntilDone:NO];}

Request Handler Block

Tuesday, March 20, 2012

Page 48: Beginning i os part 2   sam kirchmeier

JSON

{ "completed_in": 0.108, "page": 1, "results_per_page": 100, "query": "%23mobilemarch+OR+%40mobilemarchtc", ... "results": [ { "created_at": "Thu, 15 Mar 2012 16:41:16 +0000", "from_user": "teruterubouzu", "text": "@mobilemarchtc How late ...", ... }, { "created_at": "Thu, 15 Mar 2012 14:20:49 +0000", "from_user": "billyspringer", "text": "RT @smbmsp: RT @philson: ...", ...

Twitter RequestGET http://search.twitter.com/search.json

Twitter Response

Tuesday, March 20, 2012

Page 49: Beginning i os part 2   sam kirchmeier

Twitter ResponseNSData

[NSJSONSerialization JSONObjectWithData: options:0 error:&error];

Twitter Response NSData

Twitter ResponseNSDictionary

Tuesday, March 20, 2012

Page 50: Beginning i os part 2   sam kirchmeier

Demo

Tuesday, March 20, 2012

Page 51: Beginning i os part 2   sam kirchmeier

Next Steps

•Start your own app!

•Apple’s Getting Started Guide

•Apple’s Sample Code

•WWDC Videos

Tuesday, March 20, 2012

Page 52: Beginning i os part 2   sam kirchmeier

#prowess

Sam Kirchmeier, Livefront@skirchmeier

Bob McCune, TapHarmonic@bobmccune

Tuesday, March 20, 2012