• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
201104 iphone navigation-based apps
 

201104 iphone navigation-based apps

on

  • 2,735 views

 

Statistics

Views

Total Views
2,735
Views on SlideShare
2,317
Embed Views
418

Actions

Likes
5
Downloads
0
Comments
0

5 Embeds 418

http://iphone.javiergs.com 282
http://javiergs.com 133
http://translate.googleusercontent.com 1
http://www.linkedin.com 1
https://www.linkedin.com 1

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    201104 iphone navigation-based apps 201104 iphone navigation-based apps Presentation Transcript

    • iOS Programming:navigation-based applications
    • stop 1: Navigation-Based App and NSMutableArray
    • 1.1. Create a New project
    • 1.1.UITableViewControllerWindow NavigationController UITableViewController
    • 1.1.UITableViewController UITableViewDataSource UITableViewDelegateUITableViewController
    • UITableViewDataSource – tableView:cellForRowAtIndexPath: - tableView:numberOfRowsInSection:  - tableView:titleForHeaderInSection: - numberOfSectionsInTableView: UITableViewDelegate– tableView: didSelectRowAtIndexPath:- tableView: heightForHeaderInSection- tableView: viewForHeaderInSection
    • RootViewController.h NSMutableArray// RootViewController.h#import <UIKit/UIKit.h>@interface RootViewController : UITableViewController { NSMutableArray* data;}@property (nonatomic, retain) NSMutableArray* data;@end
    • RootViewController.m NSMutableArray// RootViewController.m- (void)viewDidLoad { [super viewDidLoad]; NSMutableArray* tmpArray = [[NSMutableArray alloc] initWithObjects:@”one”, @”two”, @”three”,nil]; self.data = tmpArray; [tmpArray release];}
    • RootViewController.m TableViewDataSource// RootViewController.m// Customize the number of sections in the table view.- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 1;}- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { return [self.data count];}
    • RootViewController.m TableViewDataSource // RootViewController.m // Customize the appearance of table view cells. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } // Configure the cell. cell.textLabel.text = [self.data objectAtIndex:indexPath.row]; return cell;}
    • RootViewController.m TableViewDataSource// RootViewController.m#import "RootViewController.h"@implementation RootViewController@synthesize data;- (void)dealloc { [data release]; [super viewDidLoad];}
    • Test Drive version 1.0
    • Test Drivewhat if we have a lot information...
    • stop 2: Adding Views for Details and plist
    • plist file
    • (1) plist - initialize// RootViewController.m- (void)viewDidLoad { [super viewDidLoad]; NSString *path = [[NSBundle mainBundle] pathForResource:@"data" ofType:@"plist"]; NSMutableArray* tmpArray = [[NSMutableArray alloc] initWithContentsOfFile:path]; self.data = tmpArray; [tmpArray release];}
    • UIViewController
    • file.xib
    • file.h// DetailViewController.h#import <UIKit/UIKit.h>@interface DetailViewController : UIViewController { IBOutlet UILabel *label;}@property (nonatomic, retain) UILabel *label;@end
    • file.m// DetailViewController.m#import "DetailViewController.h"@implementation DetailViewController@synthesize label, text;- (void)dealloc { [super dealloc]; [label release]; [text release];} and connect the outlet
    • stop 3: Link Table and Detail
    • RootViewController.m// RootViewController.m#import "RootViewController.h"#import "DetailViewController.h"- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil]; [self.navigationController pushViewController:detailViewController animated:YES]; [detailViewController release];}
    • Now, we have two views!
    • more and more data...
    • stop 4: Dictionaries and plist
    • dictionary.plist
    • RootViewController.m create cell from dictionary// Customize the appearance of table view cells.- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; } // Configure the cell. // cell.textLabel.text = // [self.data objectAtIndex:indexPath.row]; cell.textLabel.text = [[self.data objectAtIndex:indexPath.row] objectForKey:@"title"] return cell;}
    • RootViewController.m// RootViewController.m#import "RootViewController.h"#import "DetailViewController.h"- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { DetailViewController *detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil]; [self.navigationController pushViewController:detailViewController animated:YES]; detailViewController.row = [self.data objectAtIndex:indexPath.row]; [detailViewController release];}
    • DetailViewNSDictionary *drink;@property (nonatomic, retain) NSDictionary *drink;@synthesize row[drink release]; - (void) viewWillAppear: (BOOL)animated { [super viewWillAppear:animated]; label.text = [row objectForKey:@"title"]; text.text = [drink objectForKey:@"desc"]; }
    • stop 5: User Experince with UITableView
    • Human Interface Guide
    • RootViewController.m tableView cellForRowAtIndexPath:cell = [[[UITableViewCell alloc]initWithStyle: UITableViewCellStyleSubtitlereuseIdentifier:CellIdentifier] autorelease];cell.textLabel.text = [[self.data objectAtIndex:indexPath.row]objectForKey:@"title"];cell.detailTextLabel.text = [[self.data objectAtIndex:indexPath.row]objectForKey:@"desc"];
    • RootViewController.m tableView cellForRowAtIndexPath:cell.imageView.image =[UIImage imageNamed:@"anyFileName”];cell.accessoryType =UITableViewCellAccessoryDisclosureIndicator;
    • stop 6: Table Group
    • RootViewController.m Table View - Grouped// number of rows in the table view.- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {! if (section == 0) return 2;! if (section == 1) return 3;! if (section == 2) return 1;! else return 0;}// section- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {! NSString *title = nil;! switch (section) {! ! case 0: title = @"Behavioral patterns"; break;! ! case 1: title = @"Creational patterns"; break; XIB file:! ! case 2: title = @"Structural patterns"; break;! ! default: break; style = grouped! }! return title;}// number of section- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 3;}
    • stop 7: iAds
    • ExampleAppDelegate.h Adding a common iAds Banner// MuralistasAppDelegate.h#import <UIKit/UIKit.h>#import <iAd/iAd.h>#define SharedAdBannerView((MuralistasAppDelegate *)[[UIApplication sharedApplication] delegate]).banner@interface MuralistasAppDelegate : NSObject <UIApplicationDelegate> { ADBannerView *banner;!}@property (nonatomic, retain) IBOutlet UIWindow *window;@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;@property (nonatomic, retain) ADBannerView *banner;@end
    • ExampleAppDelegate.m Adding a common iAds Banner // didFinishLaunchingWithOptions - (BOOL) application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { // Add the navigation controllers view to the window and display. self.window.rootViewController = self.navigationController; [self.window makeKeyAndVisible]; // Banner banner = [[ADBannerView alloc] initWithFrame:CGRectZero]; // banner is pinned to the bottom ! self.banner.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleTopMargin; ! // Supported landscape or portrait [NSSet setWithObjects: ADBannerContentSizeIdentifier320x50, ADBannerContentSizeIdentifier480x32, nil];! return YES;}
    • <ADBannerViewDelegate> iAds Banner Add iAds Delegate Methods :)
    • <ADBannerViewDelegate> iAds Banner
    • .javiergs.com