Skip to content

Commit

Permalink
Navigation interface for example view controllers.
Browse files Browse the repository at this point in the history
  • Loading branch information
brow committed Apr 20, 2010
1 parent 7b18529 commit 483680c
Show file tree
Hide file tree
Showing 5 changed files with 114 additions and 6 deletions.
16 changes: 16 additions & 0 deletions Classes/ExamplesViewController.h
@@ -0,0 +1,16 @@
//
// ExamplesViewController.h
// Leaves
//
// Created by Tom Brow on 4/20/10.
// Copyright 2010 Tom Brow. All rights reserved.
//

#import <UIKit/UIKit.h>


@interface ExamplesViewController : UITableViewController {
NSArray *exampleViewControllers;
}

@end
87 changes: 87 additions & 0 deletions Classes/ExamplesViewController.m
@@ -0,0 +1,87 @@
//
// ExamplesViewController.m
// Leaves
//
// Created by Tom Brow on 4/20/10.
// Copyright 2010 Tom Brow. All rights reserved.
//

#import "ExamplesViewController.h"
#import "PDFExampleViewController.h"
#import "ImageExampleViewController.h"

@implementation ExamplesViewController



- (id)init {
if ((self = [super initWithStyle:UITableViewStyleGrouped])) {
exampleViewControllers = [[NSArray alloc] initWithObjects:
[[[PDFExampleViewController alloc] init] autorelease],
[[[ImageExampleViewController alloc] init] autorelease],
nil];
}
return self;
}

- (void)dealloc {
[exampleViewControllers release];
[super dealloc];
}


#pragma mark -
#pragma mark View lifecycle

/*
- (void)viewDidLoad {
[super viewDidLoad];
// Uncomment the following line to preserve selection between presentations.
self.clearsSelectionOnViewWillAppear = NO;
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
*/

#pragma mark UITableViewDataSource methods

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}


- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [exampleViewControllers count];
}


// 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];
}

switch (indexPath.row) {
case 0: cell.textLabel.text = @"PDF example"; break;
case 1: cell.textLabel.text = @"Image example"; break;
default: cell.textLabel.text = @"";
}
return cell;
}

#pragma mark UITableViewDelegate methods

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
UIViewController *viewController = [exampleViewControllers objectAtIndex:indexPath.row];
[self.navigationController pushViewController:viewController animated:YES];
}


@end

2 changes: 1 addition & 1 deletion Classes/LeavesAppDelegate.h
Expand Up @@ -12,7 +12,7 @@

@interface LeavesAppDelegate : NSObject <UIApplicationDelegate> {
UIWindow *window;
LeavesViewController *viewController;
UIViewController *viewController;
}

@property (nonatomic, retain) IBOutlet UIWindow *window;
Expand Down
9 changes: 4 additions & 5 deletions Classes/LeavesAppDelegate.m
Expand Up @@ -7,16 +7,15 @@
//

#import "LeavesAppDelegate.h"
#import "LeavesViewController.h"
#import "ImageExampleViewController.h"
#import "PDFExampleViewController.h"
#import "ExamplesViewController.h"

@implementation LeavesAppDelegate

@synthesize window;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
viewController = [[ImageExampleViewController alloc] init];
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
UIViewController *rootViewController = [[[ExamplesViewController alloc] init] autorelease];
viewController = [[UINavigationController alloc] initWithRootViewController:rootViewController];

[window addSubview:viewController.view];
[window makeKeyAndVisible];
Expand Down
6 changes: 6 additions & 0 deletions Leaves.xcodeproj/project.pbxproj
Expand Up @@ -24,6 +24,7 @@
D33D4ED1117D8D4500BA7203 /* MainWindow.xib in Resources */ = {isa = PBXBuildFile; fileRef = D33D4EC9117D8D4500BA7203 /* MainWindow.xib */; };
D33D4ED2117D8D4500BA7203 /* paper.pdf in Resources */ = {isa = PBXBuildFile; fileRef = D33D4ECA117D8D4500BA7203 /* paper.pdf */; };
D33D4F01117D8EAE00BA7203 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = D33D4F00117D8EAE00BA7203 /* main.m */; };
D33D4F41117E244C00BA7203 /* ExamplesViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = D33D4F40117E244C00BA7203 /* ExamplesViewController.m */; };
/* End PBXBuildFile section */

/* Begin PBXFileReference section */
Expand Down Expand Up @@ -53,6 +54,8 @@
D33D4EDA117D8DCD00BA7203 /* Leaves-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Leaves-Info.plist"; sourceTree = SOURCE_ROOT; };
D33D4EFB117D8E7800BA7203 /* Leaves_Prefix.pch */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Leaves_Prefix.pch; sourceTree = SOURCE_ROOT; };
D33D4F00117D8EAE00BA7203 /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = SOURCE_ROOT; };
D33D4F3F117E244C00BA7203 /* ExamplesViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExamplesViewController.h; sourceTree = "<group>"; };
D33D4F40117E244C00BA7203 /* ExamplesViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ExamplesViewController.m; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -79,6 +82,8 @@
D33D4A0C117C34F000BA7203 /* ImageExampleViewController.m */,
D33D4B4F117C473500BA7203 /* PDFExampleViewController.h */,
D33D4B50117C473500BA7203 /* PDFExampleViewController.m */,
D33D4F3F117E244C00BA7203 /* ExamplesViewController.h */,
D33D4F40117E244C00BA7203 /* ExamplesViewController.m */,
);
path = Classes;
sourceTree = "<group>";
Expand Down Expand Up @@ -227,6 +232,7 @@
D33D4E5C117D818100BA7203 /* LeavesViewController.m in Sources */,
D33D4ECC117D8D4500BA7203 /* Utilities.m in Sources */,
D33D4F01117D8EAE00BA7203 /* main.m in Sources */,
D33D4F41117E244C00BA7203 /* ExamplesViewController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down

0 comments on commit 483680c

Please sign in to comment.