8 #import "EnkiUnorderedController.h"
11 - (void) adjustTarget:(UIViewController *) vc withDirection:(slideDirection) direction;
12 - (void) slideCurrent:(UIViewController *) vc withDirection:(slideDirection) direction;
13 - (void) slideTarget:(UIViewController *) vc withDirection:(slideDirection) direction;
15 - (void) replaceViewController:(UIViewController *) target withDirection:(slideDirection)direction withCover:(BOOL) coverIt;
21 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
24 self = [
super initWithNibName:nil bundle:nibBundleOrNil];
31 - (void)initCurrentWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
33 Class vcClass = NSClassFromString (nibNameOrNil);
34 self.current = [[vcClass alloc] initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
38 self.current.view.frame =
self.view.frame;
40 [
self addChildViewController:self.current];
41 [
self.current didMoveToParentViewController:self];
42 [
self.view addSubview: self.current.view];
54 #pragma mark - Category methods
57 - (void) replaceViewController:(UIViewController *) target withDirection:(slideDirection) direction;
59 [
self replaceViewController:target withDirection:direction withCover:NO];
62 - (void) coverViewController:(UIViewController *) target withDirection:(slideDirection) direction;
64 [
self replaceViewController:target withDirection:direction withCover:YES];
67 - (void) uncoverViewControllerwithDirection:(slideDirection) direction;
70 [
self adjustTarget:_current withDirection:direction];
72 [UIView animateWithDuration:0.5
74 options: UIViewAnimationOptionCurveEaseInOut
77 [
self slideCurrent:_cover withDirection:direction];
80 [
self slideTarget:_current withDirection:direction];
82 completion:^(BOOL finished){
83 [_cover removeFromParentViewController];
88 #pragma mark - Extension methods
91 - (void) replaceViewController:(UIViewController *) target withDirection:(slideDirection)direction withCover:(BOOL) coverIt;
93 target.view.frame =
self.view.frame;
96 [
self addChildViewController:target];
97 [target didMoveToParentViewController:self];
98 [
self.view addSubview: target.view];
101 [
self adjustTarget:target withDirection:direction];
103 [UIView animateWithDuration:0.5
105 options: UIViewAnimationOptionCurveEaseInOut
108 [
self slideCurrent:_current withDirection:direction];
111 [
self slideTarget:target withDirection:direction];
113 completion:^(BOOL finished){
116 [_cover removeFromParentViewController];
120 [_current removeFromParentViewController];
127 - (void) slideCurrent:(UIViewController *) vc withDirection:(slideDirection) direction;
129 CGRect currentFrame = vc.view.frame;
132 currentFrame.origin.y -= currentFrame.size.height;
135 currentFrame.origin.y += currentFrame.size.height;
138 currentFrame.origin.x -= currentFrame.size.width;
141 currentFrame.origin.x += currentFrame.size.width;
147 vc.view.frame = currentFrame;
152 - (void) slideTarget:(UIViewController *) vc withDirection:(slideDirection) direction;
154 CGRect targetFrame = vc.view.frame;
157 targetFrame.origin.y = 0;
160 targetFrame.origin.y = 0;
163 targetFrame.origin.x = 0;
166 targetFrame.origin.x = 0;
172 vc.view.frame = targetFrame;
178 - (void) adjustTarget:(UIViewController *) vc withDirection:(slideDirection) direction;
180 CGRect targetFrame = vc.view.frame;
184 targetFrame.origin.y += targetFrame.size.height;
187 targetFrame.origin.y -= targetFrame.size.height;
190 targetFrame.origin.x += targetFrame.size.width;
193 targetFrame.origin.x -= targetFrame.size.width;
199 vc.view.frame = targetFrame;
203 - (void)didReceiveMemoryWarning
205 [
super didReceiveMemoryWarning];