Permalink
Browse files

Basic functionality complete.

  • Loading branch information...
1 parent af8fcc2 commit 026750c8018c676573f98eac104eb1c9a9b5186e @jeremieweldin committed Nov 22, 2011
@@ -9,11 +9,11 @@
continueAfterRunningActions = "No"
isPathRelative = "1"
filePath = "JWSlideMenu/JWSlideMenuController.m"
- timestampString = "343548065.109678"
+ timestampString = "343637742.843254"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
- startingLineNumber = "85"
- endingLineNumber = "85"
+ startingLineNumber = "69"
+ endingLineNumber = "69"
landmarkName = "-toggleMenu"
landmarkType = "5">
</FileBreakpoint>
@@ -23,11 +23,11 @@
continueAfterRunningActions = "No"
isPathRelative = "1"
filePath = "JWSlideMenu/JWSlideMenuController.m"
- timestampString = "343634174.412425"
+ timestampString = "343637742.843254"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
- startingLineNumber = "113"
- endingLineNumber = "113"
+ startingLineNumber = "103"
+ endingLineNumber = "103"
landmarkName = "-tableView:cellForRowAtIndexPath:"
landmarkType = "5">
</FileBreakpoint>
@@ -37,11 +37,11 @@
continueAfterRunningActions = "No"
isPathRelative = "1"
filePath = "JWSlideMenu/JWSlideMenuController.m"
- timestampString = "343634174.412425"
+ timestampString = "343637742.843254"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
- startingLineNumber = "135"
- endingLineNumber = "135"
+ startingLineNumber = "125"
+ endingLineNumber = "125"
landmarkName = "-tableView:numberOfRowsInSection:"
landmarkType = "5">
</FileBreakpoint>
@@ -51,11 +51,11 @@
continueAfterRunningActions = "No"
isPathRelative = "1"
filePath = "JWSlideMenu/JWSlideMenuController.m"
- timestampString = "343634174.412425"
+ timestampString = "343637742.843254"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
- startingLineNumber = "136"
- endingLineNumber = "136"
+ startingLineNumber = "126"
+ endingLineNumber = "126"
landmarkName = "-tableView:numberOfRowsInSection:"
landmarkType = "5">
</FileBreakpoint>
@@ -65,13 +65,41 @@
continueAfterRunningActions = "No"
isPathRelative = "1"
filePath = "JWSlideMenu/JWSlideMenuController.m"
- timestampString = "343547385.395905"
+ timestampString = "343637742.843254"
startingColumnNumber = "9223372036854775807"
endingColumnNumber = "9223372036854775807"
- startingLineNumber = "31"
- endingLineNumber = "31"
+ startingLineNumber = "30"
+ endingLineNumber = "30"
landmarkName = "-init"
landmarkType = "5">
</FileBreakpoint>
+ <FileBreakpoint
+ shouldBeEnabled = "No"
+ ignoreCount = "0"
+ continueAfterRunningActions = "No"
+ isPathRelative = "1"
+ filePath = "JWSlideMenu/JWNavigationController.m"
+ timestampString = "343641537.28497"
+ startingColumnNumber = "9223372036854775807"
+ endingColumnNumber = "9223372036854775807"
+ startingLineNumber = "60"
+ endingLineNumber = "60"
+ landmarkName = "-initWithRootViewController:"
+ landmarkType = "5">
+ </FileBreakpoint>
+ <FileBreakpoint
+ shouldBeEnabled = "No"
+ ignoreCount = "0"
+ continueAfterRunningActions = "No"
+ isPathRelative = "1"
+ filePath = "JWSlideMenu/JWSlideMenuController.m"
+ timestampString = "343638220.898907"
+ startingColumnNumber = "9223372036854775807"
+ endingColumnNumber = "9223372036854775807"
+ startingLineNumber = "95"
+ endingLineNumber = "95"
+ landmarkName = "-addViewController:"
+ landmarkType = "5">
+ </FileBreakpoint>
</FileBreakpoints>
</Bucket>
@@ -14,7 +14,7 @@ - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
- // Custom initialization
+ self.title = @"First";
}
return self;
}
@@ -38,10 +38,9 @@
<object class="IBUILabel" id="965923764">
<reference key="NSNextResponder" ref="191373211"/>
<int key="NSvFlags">301</int>
- <string key="NSFrame">{{139, 219}, {42, 21}}</string>
+ <string key="NSFrame">{{139, 197}, {42, 21}}</string>
<reference key="NSSuperview" ref="191373211"/>
<reference key="NSWindow"/>
- <reference key="NSNextKeyView"/>
<string key="NSReuseIdentifierKey">_NS:328</string>
<bool key="IBUIOpaque">NO</bool>
<bool key="IBUIClipsSubviews">YES</bool>
@@ -68,7 +67,7 @@
</object>
</object>
</array>
- <string key="NSFrame">{{0, 20}, {320, 460}}</string>
+ <string key="NSFrame">{{0, 64}, {320, 416}}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="965923764"/>
@@ -80,6 +79,9 @@
</object>
</object>
<object class="IBUISimulatedStatusBarMetrics" key="IBUISimulatedStatusBarMetrics"/>
+ <object class="IBUISimulatedNavigationBarMetrics" key="IBUISimulatedTopBarMetrics">
+ <bool key="IBUIPrompted">NO</bool>
+ </object>
<string key="targetRuntimeIdentifier">IBCocoaTouchFramework</string>
</object>
</array>
@@ -140,7 +142,7 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
- <int key="maxID">4</int>
+ <int key="maxID">12</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -8,6 +8,7 @@
#import "JWAppDelegate.h"
#import "JWSlideMenuController.h"
+#import "JWNavigationController.h"
#import "FirstViewController.h"
#import "SecondViewController.h"
@@ -28,17 +29,27 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
self.window.backgroundColor = [UIColor whiteColor];
UIViewController *f = [[FirstViewController alloc]initWithNibName:@"FirstViewController" bundle:nil];
- f.title = @"First";
+ //f.title = @"First";
+
+ JWNavigationController *fNav = [[JWNavigationController alloc] initWithRootViewController:f];
+
+
UIViewController *s = [[SecondViewController alloc]initWithNibName:@"SecondViewController" bundle:nil];
- s.title = @"Second";
+ //s.title = @"Second";
+
+ JWNavigationController *sNav = [[JWNavigationController alloc] initWithRootViewController:s];
+
JWSlideMenuController *slideMenu = [[[JWSlideMenuController alloc] init] autorelease];
- [slideMenu addViewController:f];
- [slideMenu addViewController:s];
+ [slideMenu addViewController:fNav];
+ [slideMenu addViewController:sNav];
self.window.rootViewController = slideMenu;
+
+ [fNav release];
+ [sNav release];
[f release];
[s release];
@@ -7,9 +7,17 @@
//
#import <UIKit/UIKit.h>
+@class JWSlideMenuController;
@interface JWNavigationController : UIViewController
@property (nonatomic, retain) UINavigationBar *navigationBar;
+@property (nonatomic, retain) UIView *contentView;
+@property (nonatomic, retain) JWSlideMenuController *slideMenuController;
+@property (nonatomic, retain, readonly) UIViewController *rootViewController;
+
+- (id)initWithRootViewController:(UIViewController *)rootViewController;
+- (void)pushViewController:(UIViewController *)controller;
+- (UIViewController *)popViewController;
@end
@@ -11,6 +11,9 @@
@implementation JWNavigationController
@synthesize navigationBar;
+@synthesize contentView;
+@synthesize slideMenuController;
+@synthesize rootViewController=_rootViewController;
- (void)didReceiveMemoryWarning
{
@@ -22,17 +25,54 @@ - (void)didReceiveMemoryWarning
#pragma mark - View lifecycle
+- (id)init
+{
+ self = [super init];
+ if (self) {
+
+ CGRect masterRect = [[UIScreen mainScreen] bounds];
+
+ CGRect contentFrame = CGRectMake(0.0, 44.0, masterRect.size.width, masterRect.size.height - 44.0);
+ CGRect navBarFrame = CGRectMake(0.0, 0.0, masterRect.size.width, 44.0);
+
+ self.view = [[[UIView alloc] initWithFrame:masterRect] autorelease];
+ self.view.autoresizingMask = UIViewAutoresizingFlexibleWidth;
+ self.view.backgroundColor = [UIColor magentaColor];
+
+ self.contentView = [[[UIView alloc] initWithFrame:contentFrame] autorelease];
+ self.contentView.backgroundColor = [UIColor whiteColor];
+ self.contentView.autoresizingMask = UIViewAutoresizingFlexibleWidth;
+ [self.view addSubview:self.contentView];
+
+ self.navigationBar = [[[UINavigationBar alloc] initWithFrame:navBarFrame] autorelease];
+ self.navigationBar.autoresizingMask = UIViewAutoresizingFlexibleWidth;
+ //[self.navigationBar pushNavigationItem:[[UINavigationItem alloc] initWithTitle:@"SlideMenu"] animated:NO];
+ //UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"menu_icon_20x20.png"] style:UIBarButtonItemStyleBordered target:self.slideMenuController action:@selector(toggleMenu)];
+ [self.view insertSubview:self.navigationBar aboveSubview:self.contentView];
+
+ }
+ return self;
+}
+
+
+- (id)initWithRootViewController:(UIViewController *)rootViewController
+{
+ self = [self init];
+ if(self) {
+ _rootViewController = rootViewController;
+ UIBarButtonItem *menuButton = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"menu_icon_20x20.png"] style:UIBarButtonItemStyleBordered target:self.slideMenuController action:@selector(toggleMenu)];
+ rootViewController.navigationItem.leftBarButtonItem = menuButton;
+ [self addChildViewController:rootViewController];
+ [self.contentView addSubview:rootViewController.view];
+ [self.navigationBar pushNavigationItem:rootViewController.navigationItem animated:YES];
+ }
+ return self;
+}
+
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView
{
- CGRect masterRect = self.view.bounds;
- CGRect contentWrapperFrame = masterRect;
- CGRect contentFrame = CGRectMake(0.0, 44.0, masterRect.size.width, masterRect.size.height - 44);
- CGRect navBarFrame = CGRectMake(0.0, 0.0, masterRect.size.width, 44);
-
- self.navigationBar = [[UINavigationBar alloc] initWithFrame:navBarFrame];
- [self.view addSubview:self.navigationBar];
}
/*
@@ -43,16 +83,54 @@ - (void)viewDidLoad
}
*/
+- (void)pushViewController:(UIViewController *)controller
+{
+ [self addChildViewController:controller];
+ [self.navigationBar pushNavigationItem:controller.navigationItem animated:YES];
+
+ if([self.childViewControllers count] == 1)
+ {
+ [self.contentView addSubview:controller.view];
+ }
+ else
+ {
+ UIViewController *previousController = [self.childViewControllers lastObject];
+ [self transitionFromViewController:previousController toViewController:controller duration:0.5 options:UIViewAnimationOptionTransitionFlipFromRight animations:NULL completion:NULL];
+ }
+}
+
+- (UIViewController *)popViewController
+{
+ UIViewController *controller = [self.childViewControllers lastObject];
+ UIViewController *previousController = nil;
+ if([self.childViewControllers count] > 1)
+ {
+ previousController = [self.childViewControllers objectAtIndex:[self.childViewControllers count]-1];
+ }
+ [controller removeFromParentViewController];
+ [self.navigationBar popNavigationItemAnimated:YES];
+ [self transitionFromViewController:controller toViewController:previousController duration:0.5 options:UIViewAnimationOptionTransitionFlipFromLeft animations:NULL completion:NULL];
+
+ return controller;
+}
+
- (void)viewDidUnload
{
+ _rootViewController = nil;
self.navigationBar = nil;
+ self.contentView = nil;
+
+ self.slideMenuController = nil;
+
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
+ [_rootViewController release];
[navigationBar release];
+ [contentView release];
[super dealloc];
}
@@ -13,9 +13,7 @@
@property (retain, nonatomic) UITableView *menuTableView;
@property (retain, nonatomic) UIView *menuView;
@property (retain, nonatomic) UIToolbar *contentToolbar;
-@property (retain, nonatomic) UIView *contentWrapperView;
@property (retain, nonatomic) UIView *contentView;
-@property (retain, nonatomic) UIBarButtonItem *menuButton;
@property (retain, nonatomic) UIColor *menuLabelColor;
-(IBAction)toggleMenu;
Oops, something went wrong.

0 comments on commit 026750c

Please sign in to comment.