Skip to content

Commit

Permalink
version 2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Joan Lluch committed Jul 3, 2014
1 parent 94dc998 commit e864226
Show file tree
Hide file tree
Showing 22 changed files with 961 additions and 189 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,14 @@

A UIViewController subclass for revealing a rear (left and/or right) view controller behind a front controller, inspired by the Facebook app, done right!


## NOTE ( Upgrading to Version 2.1)

This version incorporates a new approach to Story Boards support.

* There are now two different segue classes, SWRevealViewControllerSegueSetController and SWRevealViewControllerSeguePushController. The first one is meant to set the revealViewController with the initial controllers from the story board. The second one is used to push controllers to the front with animation. The former SWRevealViewControllerSegue still works but it has been deprecated.
* A new StoryBoard example, RevealControllerStoryBoardExample2, has been added to demonstrate the use of the new segue classes. More responsability has been moved to the Story Board design while simplifying the SWRevealViewController implementation.

## IMPORTANT NOTE: (Upgrading to Version 2.0)

A number of changes have been made on version 2.0 that may break your existing project. In case you are not ready to upgrade you can continue using previous versions. The last commit before 2.0.0 was tagged v1.1.3. The important changes that affect 2.0.0 are described next.
Expand Down
Binary file modified RevealControllerStoryboardExample/.DS_Store
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// AppDelegate.h
// RevealControllerStoryboardExample
//
// Created by Nick Hodapp on 1/9/13.
// Copyright (c) 2013 CoDeveloper. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
//
// AppDelegate.m
// RevealControllerStoryboardExample
//
// Created by Nick Hodapp on 1/9/13.
// Copyright (c) 2013 CoDeveloper. All rights reserved.
//

#import "AppDelegate.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
//
// ColorViewController.h
// RevealControllerStoryboardExample
//
// Created by Nick Hodapp on 1/9/13.
// Copyright (c) 2013 CoDeveloper. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface ColorViewController : UIViewController
@property (nonatomic, strong) IBOutlet UILabel* label;
@property (nonatomic, strong) UIColor* color;
@property (nonatomic, strong) NSString* text;
@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//
// ColorViewController.m
// RevealControllerStoryboardExample
//
// Created by Nick Hodapp on 1/9/13.
// Copyright (c) 2013 CoDeveloper. All rights reserved.
//

#import "ColorViewController.h"

@interface ColorViewController ()
@property (nonatomic) IBOutlet UIBarButtonItem* revealButtonItem;
@end

@implementation ColorViewController

- (void)viewDidLoad
{
[super viewDidLoad];

[self.revealButtonItem setTarget: self.revealViewController];
[self.revealButtonItem setAction: @selector( revealToggle: )];
[self.navigationController.navigationBar addGestureRecognizer: self.revealViewController.panGestureRecognizer];

_label.text = _text;
_label.textColor = _color;
}

@end
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//
// MapViewController.h
// RevealControllerStoryboardExample
//
// Created by Nick Hodapp on 1/9/13.
// Copyright (c) 2013 CoDeveloper. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface MapViewController : UIViewController

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
//
// MapViewController.m
// RevealControllerStoryboardExample
//
// Created by Nick Hodapp on 1/9/13.
// Copyright (c) 2013 CoDeveloper. All rights reserved.
//

#import "MapViewController.h"

@interface MapViewController ()
@property (nonatomic) IBOutlet UIBarButtonItem* revealButtonItem;
@end

@implementation MapViewController

- (void)viewDidLoad
{
[super viewDidLoad];

[self.revealButtonItem setTarget: self.revealViewController];
[self.revealButtonItem setAction: @selector( revealToggle: )];
[self.navigationController.navigationBar addGestureRecognizer: self.revealViewController.panGestureRecognizer];
}

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
//
// MenuViewController.h
// RevealControllerStoryboardExample
//
// Created by Nick Hodapp on 1/9/13.
// Copyright (c) 2013 CoDeveloper. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface SWUITableViewCell : UITableViewCell
@property (nonatomic) IBOutlet UILabel *label;
@end

@interface MenuViewController : UITableViewController

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
//
// MenuViewController.m
// RevealControllerStoryboardExample
//
// Created by Nick Hodapp on 1/9/13.
// Copyright (c) 2013 CoDeveloper. All rights reserved.
//

#import "MenuViewController.h"
#import "ColorViewController.h"

@implementation SWUITableViewCell
@end

@implementation MenuViewController

- (void) prepareForSegueB: (UIStoryboardSegue *) segue sender: (id) sender
{
// configure the destination view controller:
if ( [segue.destinationViewController isKindOfClass: [ColorViewController class]] &&
[sender isKindOfClass:[UITableViewCell class]] )
{
UILabel* c = [(SWUITableViewCell *)sender label];
ColorViewController* cvc = segue.destinationViewController;

cvc.color = c.textColor;
cvc.text = c.text;
}

// configure the segue.
if ( [segue isKindOfClass: [SWRevealViewControllerSegue class]] )
{
SWRevealViewControllerSegue* rvcs = (SWRevealViewControllerSegue*) segue;

SWRevealViewController* rvc = self.revealViewController;
NSAssert( rvc != nil, @"oops! must have a revealViewController" );

NSAssert( [rvc.frontViewController isKindOfClass: [UINavigationController class]], @"oops! for this segue we want a permanent navigation controller in the front!" );

rvcs.performBlock = ^(SWRevealViewControllerSegue* rvc_segue, UIViewController* svc, UIViewController* dvc)
{
UINavigationController* nc = [[UINavigationController alloc] initWithRootViewController:dvc];
[rvc pushFrontViewController:nc animated:YES];
};
}
}


- (void) prepareForSegue: (UIStoryboardSegue *) segue sender: (id) sender
{
// configure the destination view controller:
if ( [sender isKindOfClass:[UITableViewCell class]] )
{
UILabel* c = [(SWUITableViewCell *)sender label];
UINavigationController *navController = segue.destinationViewController;
ColorViewController* cvc = [navController childViewControllers].firstObject;
if ( [cvc isKindOfClass:[ColorViewController class]] )
{
cvc.color = c.textColor;
cvc.text = c.text;
}
}
}


#pragma mark - Table view data source

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

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 3;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";

switch ( indexPath.row )
{
case 0:
CellIdentifier = @"map";
break;

case 1:
CellIdentifier = @"blue";
break;

case 2:
CellIdentifier = @"red";
break;
}

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier: CellIdentifier forIndexPath: indexPath];

return cell;
}

@end
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/* Localized versions of Info.plist keys */

Loading

0 comments on commit e864226

Please sign in to comment.