beginning i os part 2 sam kirchmeier

Post on 10-May-2015

910 Views

Category:

Technology

3 Downloads

Preview:

Click to see full reader

DESCRIPTION

Mobile March 2012

TRANSCRIPT

iOS TrainingPart 2

Sam Kirchmeiersam@livefront.com

@skirchmeier

Tuesday, March 20, 2012

Topics

•Storyboards

•Navigation Controllers

•Table View Controllers

Tuesday, March 20, 2012

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

Storyboards

Tuesday, March 20, 2012

ScenesView Controllers

SeguesTransitions

Tuesday, March 20, 2012

Tuesday, March 20, 2012

Scene

Tuesday, March 20, 2012

Scene

Segue

Tuesday, March 20, 2012

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

Demo

Tuesday, March 20, 2012

Goal #1Display a list of sessions

Tuesday, March 20, 2012

Navigation Controller

Tuesday, March 20, 2012

Tuesday, March 20, 2012

Tuesday, March 20, 2012

View Controller 1 View Controller 2

Tuesday, March 20, 2012

Demo

Tuesday, March 20, 2012

Table View Controller

Tuesday, March 20, 2012

Tuesday, March 20, 2012

Tuesday, March 20, 2012

Navigation Controller

Tuesday, March 20, 2012

Navigation Controller

View Controller

Tuesday, March 20, 2012

Navigation Controller

View Controller

Table View

Tuesday, March 20, 2012

Navigation Controller

View Controller

Table View

Navigation Controller

Table View Controller

Table ViewBuilt In

Tuesday, March 20, 2012

Navigation Controller

View Controller

Table View

Tuesday, March 20, 2012

Navigation Controller

View Controller

Table View

Delegate

Data Source

Tuesday, March 20, 2012

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

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

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

Navigation Controller

Table View Controller

Table ViewBuilt In

Tuesday, March 20, 2012

Navigation Controller

Table View Controller

Table ViewBuilt In

Data Source

Delegate

Tuesday, March 20, 2012

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

UITableViewDelegate– tableView:didSelectRowAtIndexPath:

– tableView:heightForRowAtIndexPath:

– tableView:viewForHeaderInSection:

– tableView:viewForFooterInSection:

(and lots more)

Tuesday, March 20, 2012

UITableViewCell

Tuesday, March 20, 2012

Basic

Tuesday, March 20, 2012

Right Detail

Tuesday, March 20, 2012

Left Detail

Tuesday, March 20, 2012

Subtitle

Tuesday, March 20, 2012

Demo

Tuesday, March 20, 2012

Goal #2Display a Twitter feed

Tuesday, March 20, 2012

Twitter Framework

Tuesday, March 20, 2012

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

^(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

Threads[request performRequestWithHandler: ];Request Handler Block

This handler is not guaranteed to be called on any particular

thread.

Apple

Tuesday, March 20, 2012

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

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

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

Twitter ResponseNSData

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

Twitter Response NSData

Twitter ResponseNSDictionary

Tuesday, March 20, 2012

Demo

Tuesday, March 20, 2012

Next Steps

•Start your own app!

•Apple’s Getting Started Guide

•Apple’s Sample Code

•WWDC Videos

Tuesday, March 20, 2012

#prowess

Sam Kirchmeier, Livefront@skirchmeier

Bob McCune, TapHarmonic@bobmccune

Tuesday, March 20, 2012

top related