Permalink
Browse files

Finished MultiViewDeckExample.

  • Loading branch information...
1 parent 71b891a commit dd3b83f0745e0e75c4d9d3e3a19b0088c71e4d19 @Inferis Inferis committed May 10, 2012
@@ -22,6 +22,8 @@
E267169515569A3800E0C3C0 /* BottomViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E267169315569A3800E0C3C0 /* BottomViewController.m */; };
E267169615569A3800E0C3C0 /* BottomViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E267169415569A3800E0C3C0 /* BottomViewController.xib */; };
E267169A15569BA100E0C3C0 /* UITableViewCell+AutoDequeue.m in Sources */ = {isa = PBXBuildFile; fileRef = E267169915569BA100E0C3C0 /* UITableViewCell+AutoDequeue.m */; };
+ E2B01A33155BE2D400E05FB9 /* ModalViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = E2B01A31155BE2D300E05FB9 /* ModalViewController.m */; };
+ E2B01A34155BE2D400E05FB9 /* ModalViewController.xib in Resources */ = {isa = PBXBuildFile; fileRef = E2B01A32155BE2D300E05FB9 /* ModalViewController.xib */; };
/* End PBXBuildFile section */
/* Begin PBXFileReference section */
@@ -50,6 +52,9 @@
E267169415569A3800E0C3C0 /* BottomViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = BottomViewController.xib; sourceTree = "<group>"; };
E267169815569BA100E0C3C0 /* UITableViewCell+AutoDequeue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UITableViewCell+AutoDequeue.h"; sourceTree = "<group>"; };
E267169915569BA100E0C3C0 /* UITableViewCell+AutoDequeue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UITableViewCell+AutoDequeue.m"; sourceTree = "<group>"; };
+ E2B01A30155BE2D300E05FB9 /* ModalViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ModalViewController.h; sourceTree = "<group>"; };
+ E2B01A31155BE2D300E05FB9 /* ModalViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ModalViewController.m; sourceTree = "<group>"; };
+ E2B01A32155BE2D300E05FB9 /* ModalViewController.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = ModalViewController.xib; sourceTree = "<group>"; };
/* End PBXFileReference section */
/* Begin PBXFrameworksBuildPhase section */
@@ -109,6 +114,9 @@
E267168D155699AF00E0C3C0 /* CenterViewController.h */,
E267168E155699AF00E0C3C0 /* CenterViewController.m */,
E267168F155699AF00E0C3C0 /* CenterViewController.xib */,
+ E2B01A30155BE2D300E05FB9 /* ModalViewController.h */,
+ E2B01A31155BE2D300E05FB9 /* ModalViewController.m */,
+ E2B01A32155BE2D300E05FB9 /* ModalViewController.xib */,
);
path = MultiViewDeckExample;
sourceTree = "<group>";
@@ -209,6 +217,7 @@
E267168C1556998700E0C3C0 /* LeftViewController.xib in Resources */,
E2671691155699AF00E0C3C0 /* CenterViewController.xib in Resources */,
E267169615569A3800E0C3C0 /* BottomViewController.xib in Resources */,
+ E2B01A34155BE2D400E05FB9 /* ModalViewController.xib in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -227,6 +236,7 @@
E2671690155699AF00E0C3C0 /* CenterViewController.m in Sources */,
E267169515569A3800E0C3C0 /* BottomViewController.m in Sources */,
E267169A15569BA100E0C3C0 /* UITableViewCell+AutoDequeue.m in Sources */,
+ E2B01A33155BE2D400E05FB9 /* ModalViewController.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@@ -261,7 +271,7 @@
);
GCC_SYMBOLS_PRIVATE_EXTERN = NO;
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
- GCC_TREAT_WARNINGS_AS_ERRORS = YES;
+ GCC_TREAT_WARNINGS_AS_ERRORS = NO;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
@@ -281,7 +291,7 @@
COPY_PHASE_STRIP = YES;
GCC_C_LANGUAGE_STANDARD = gnu99;
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
- GCC_TREAT_WARNINGS_AS_ERRORS = YES;
+ GCC_TREAT_WARNINGS_AS_ERRORS = NO;
GCC_VERSION = com.apple.compilers.llvm.clang.1_0;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
@@ -20,48 +20,23 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIViewController* leftController = [[LeftViewController alloc] initWithNibName:@"LeftViewController" bundle:nil];
+ leftController = [[UINavigationController alloc] initWithRootViewController:leftController];
+
UIViewController* bottomController = [[BottomViewController alloc] initWithNibName:@"BottomViewController" bundle:nil];
+ bottomController = [[UINavigationController alloc] initWithRootViewController:bottomController];
+
UIViewController *centerController = [[CenterViewController alloc] initWithNibName:@"CenterViewController" bundle:nil];
+ centerController = [[UINavigationController alloc] initWithRootViewController:centerController];
IIViewDeckController* secondDeckController = [[IIViewDeckController alloc] initWithCenterViewController:leftController
leftViewController:bottomController];
- secondDeckController.leftLedge = 88;
-
- centerController = [[UINavigationController alloc] initWithRootViewController:centerController];
+ secondDeckController.leftLedge = 66;
IIViewDeckController* deckController = [[IIViewDeckController alloc] initWithCenterViewController:centerController
leftViewController:secondDeckController];
- deckController.leftLedge = 44;
self.window.rootViewController = deckController;
[self.window makeKeyAndVisible];
return YES;
}
-- (void)applicationWillResignActive:(UIApplication *)application
-{
- // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
- // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
-}
-
-- (void)applicationDidEnterBackground:(UIApplication *)application
-{
- // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
- // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
-}
-
-- (void)applicationWillEnterForeground:(UIApplication *)application
-{
- // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
-}
-
-- (void)applicationDidBecomeActive:(UIApplication *)application
-{
- // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
-}
-
-- (void)applicationWillTerminate:(UIApplication *)application
-{
- // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
-}
-
@end
@@ -8,6 +8,8 @@
#import "BottomViewController.h"
#import "UITableViewCell+AutoDequeue.h"
+#import "IIViewDeckController.h"
+#import "ModalViewController.h"
@interface BottomViewController ()
@@ -28,11 +30,7 @@ - (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;
+ self.navigationController.navigationBar.tintColor = [UIColor colorWithWhite:0.4 alpha:1];
}
- (void)viewDidUnload
@@ -54,6 +52,10 @@ - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
return 2;
}
+- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
+ return [NSString stringWithFormat:@"%i", section];
+}
+
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return (section+1)*2;
@@ -63,61 +65,22 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
{
UITableViewCell *cell = [UITableViewCell tableViewAutoDequeueCell:tableView];
- cell.textLabel.text = @"Bottom";
+ cell.textLabel.text = indexPath.section ? @"Close Toplevel" : @"Modal";
return cell;
}
-/*
-// Override to support conditional editing of the table view.
-- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
-{
- // Return NO if you do not want the specified item to be editable.
- return YES;
-}
-*/
-
-/*
-// Override to support editing the table view.
-- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
-{
- if (editingStyle == UITableViewCellEditingStyleDelete) {
- // Delete the row from the data source
- [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
- }
- else if (editingStyle == UITableViewCellEditingStyleInsert) {
- // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
- }
-}
-*/
-
-/*
-// Override to support rearranging the table view.
-- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
-{
-}
-*/
-
-/*
-// Override to support conditional rearranging of the table view.
-- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
-{
- // Return NO if you do not want the item to be re-orderable.
- return YES;
-}
-*/
-
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
- // Navigation logic may go here. Create and push another view controller.
- /*
- <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
- // ...
- // Pass the selected object to the new view controller.
- [self.navigationController pushViewController:detailViewController animated:YES];
- */
+ if (indexPath.section) {
+ [self.viewDeckController.viewDeckController closeLeftView];
+ }
+ else {
+ ModalViewController* modal = [[ModalViewController alloc] initWithNibName:@"ModalViewController" bundle:nil];
+ [self presentModalViewController:modal animated:YES];
+ }
}
@end
@@ -8,6 +8,8 @@
#import "CenterViewController.h"
#import "UITableViewCell+AutoDequeue.h"
+#import "IIViewDeckController.h"
+#import "ModalViewController.h"
@interface CenterViewController ()
@@ -27,33 +29,40 @@ - (id)initWithStyle:(UITableViewStyle)style
- (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;
+
+ self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRewind target:self.viewDeckController action:@selector(toggleLeftView)];
+ self.navigationController.navigationBar.tintColor = [UIColor purpleColor];
}
-- (void)viewDidUnload
-{
- [super viewDidUnload];
- // Release any retained subviews of the main view.
- // e.g. self.myOutlet = nil;
-}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
+- (BOOL)viewDeckControllerWillOpenLeftView:(IIViewDeckController *)viewDeckController animated:(BOOL)animated {
+ self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFastForward target:self.viewDeckController action:@selector(toggleLeftView)];
+ return YES;
+}
+
+- (BOOL)viewDeckControllerWillCloseLeftView:(IIViewDeckController *)viewDeckController animated:(BOOL)animated {
+ self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRewind target:self.viewDeckController action:@selector(toggleLeftView)];
+ [(IIViewDeckController*)self.viewDeckController.leftController closeLeftView];
+ return YES;
+}
+
#pragma mark - Table view data source
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 4;
}
+- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section {
+ return [NSString stringWithFormat:@"%i", section];
+}
+
+
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return (section+1)*4;
@@ -63,60 +72,22 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
{
UITableViewCell *cell = [UITableViewCell tableViewAutoDequeueCell:tableView];
- cell.textLabel.text = @"Center";
+ cell.textLabel.text = indexPath.section % 2 ? @"Close Me" : @"Modal";
return cell;
}
-/*
-// Override to support conditional editing of the table view.
-- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
-{
- // Return NO if you do not want the specified item to be editable.
- return YES;
-}
-*/
-
-/*
-// Override to support editing the table view.
-- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
-{
- if (editingStyle == UITableViewCellEditingStyleDelete) {
- // Delete the row from the data source
- [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
- }
- else if (editingStyle == UITableViewCellEditingStyleInsert) {
- // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
- }
-}
-*/
-
-/*
-// Override to support rearranging the table view.
-- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
-{
-}
-*/
-
-/*
-// Override to support conditional rearranging of the table view.
-- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
-{
- // Return NO if you do not want the item to be re-orderable.
- return YES;
-}
-*/
#pragma mark - Table view delegate
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
- // Navigation logic may go here. Create and push another view controller.
- /*
- <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
- // ...
- // Pass the selected object to the new view controller.
- [self.navigationController pushViewController:detailViewController animated:YES];
- */
+ if (indexPath.section % 2) {
+ [self.viewDeckController closeLeftView];
+ }
+ else {
+ ModalViewController* modal = [[ModalViewController alloc] initWithNibName:@"ModalViewController" bundle:nil];
+ [self presentModalViewController:modal animated:YES];
+ }
}
@end
Oops, something went wrong.

0 comments on commit dd3b83f

Please sign in to comment.