From f740142efd2ef38d53078941effe11b15a857bc8 Mon Sep 17 00:00:00 2001 From: Anthony Detamore Date: Wed, 3 Sep 2014 13:04:03 -0400 Subject: [PATCH 1/4] Update AnimatedTransitioning.h --- Transition Delegate/AnimatedTransitioning.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Transition Delegate/AnimatedTransitioning.h b/Transition Delegate/AnimatedTransitioning.h index 2f4d0cb..befa5b7 100644 --- a/Transition Delegate/AnimatedTransitioning.h +++ b/Transition Delegate/AnimatedTransitioning.h @@ -10,6 +10,6 @@ @interface AnimatedTransitioning : NSObject -@property (nonatomic, assign) BOOL isPresenting; +@property (nonatomic, assign) BOOL reverse; @end From e6c2e86b064d211712860b683d32230f5d4a67e0 Mon Sep 17 00:00:00 2001 From: Anthony Detamore Date: Wed, 3 Sep 2014 13:06:14 -0400 Subject: [PATCH 2/4] Update AnimatedTransitioning.m --- Transition Delegate/AnimatedTransitioning.m | 38 ++++++++++++++++----- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/Transition Delegate/AnimatedTransitioning.m b/Transition Delegate/AnimatedTransitioning.m index c346517..67b41c2 100644 --- a/Transition Delegate/AnimatedTransitioning.m +++ b/Transition Delegate/AnimatedTransitioning.m @@ -3,12 +3,11 @@ // CustomTransitionExample // // Created by Blanche Faur on 10/24/13. +// Updated by Anthony Detamore on 9/03/14 // Copyright (c) 2013 Blanche Faur. All rights reserved. // #import "AnimatedTransitioning.h" -#import "MainViewController.h" -#import "SecondViewController.h" @implementation AnimatedTransitioning @@ -20,20 +19,28 @@ - (NSTimeInterval)transitionDuration:(id ) return 0.25f; } -- (void)animateTransition:(id )transitionContext { +- (void)animateTransition:(id )transitionContext +{ + UIViewController* toVC = (UIViewController*)[transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; + UIViewController* fromVC = (UIViewController *)[transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; - UIView *inView = [transitionContext containerView]; - SecondViewController *toVC = (SecondViewController *)[transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; - MainViewController *fromVC = (MainViewController *)[transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; + if(self.reverse) { + [self executeReverseAnimation:transitionContext fromVC:fromVC toVC:toVC]; + } else { + [self executeForwardAnimation:transitionContext fromVC:fromVC toVC:toVC]; + } - [inView addSubview:toVC.view]; +} + +-(void)executeForwardAnimation:(id)transitionContext fromVC:(UIViewController *)fromVC toVC:(UIViewController *)toVC +{ + [[transitionContext containerView] addSubview:toVC.view]; CGRect screenRect = [[UIScreen mainScreen] bounds]; [toVC.view setFrame:CGRectMake(0, screenRect.size.height, fromVC.view.frame.size.width, fromVC.view.frame.size.height)]; [UIView animateWithDuration:0.25f animations:^{ - [toVC.view setFrame:CGRectMake(0, 0, fromVC.view.frame.size.width, fromVC.view.frame.size.height)]; } completion:^(BOOL finished) { @@ -41,5 +48,20 @@ - (void)animateTransition:(id )transitionC }]; } +-(void)executeReverseAnimation:(id)transitionContext fromVC:(UIViewController *)fromVC toVC:(UIViewController *)toVC +{ + [[transitionContext containerView] insertSubview:toVC.view belowSubview:fromVC.view]; + + CGRect screenRect = [[UIScreen mainScreen] bounds]; + + [UIView animateWithDuration:0.25f + animations:^{ + [fromVC.view setFrame:CGRectMake(0, screenRect.size.height, fromVC.view.frame.size.width, fromVC.view.frame.size.height)]; + } + completion:^(BOOL finished) { + [transitionContext completeTransition:YES]; + }]; +} + @end From d8670300279e874f1f47ca81682b5737ff4b6ba2 Mon Sep 17 00:00:00 2001 From: Anthony Detamore Date: Wed, 3 Sep 2014 13:06:48 -0400 Subject: [PATCH 3/4] Update AnimatedTransitioning.h --- Transition Delegate/AnimatedTransitioning.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Transition Delegate/AnimatedTransitioning.h b/Transition Delegate/AnimatedTransitioning.h index befa5b7..36184f4 100644 --- a/Transition Delegate/AnimatedTransitioning.h +++ b/Transition Delegate/AnimatedTransitioning.h @@ -3,6 +3,7 @@ // CustomTransitionExample // // Created by Blanche Faur on 10/24/13. +// Updated by Anthony Detamore on 9/03/14. // Copyright (c) 2013 Blanche Faur. All rights reserved. // From 5dd9c1d24d6567d6e6f5bb9cbe21319ed31b57a9 Mon Sep 17 00:00:00 2001 From: Anthony Detamore Date: Wed, 3 Sep 2014 13:07:54 -0400 Subject: [PATCH 4/4] Update TransitionDelegate.m --- Transition Delegate/TransitionDelegate.m | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Transition Delegate/TransitionDelegate.m b/Transition Delegate/TransitionDelegate.m index 23c31b9..b91bcf2 100644 --- a/Transition Delegate/TransitionDelegate.m +++ b/Transition Delegate/TransitionDelegate.m @@ -3,6 +3,7 @@ // CustomTransitionExample // // Created by Blanche Faur on 10/24/13. +// Updated by Anthony Detamore on 9/03/14. // Copyright (c) 2013 Blanche Faur. All rights reserved. // @@ -17,17 +18,15 @@ @implementation TransitionDelegate //=================================================================== - (id )animationControllerForPresentedController:(UIViewController *)presented presentingController:(UIViewController *)presenting sourceController:(UIViewController *)source { - AnimatedTransitioning *controller = [[AnimatedTransitioning alloc]init]; - controller.isPresenting = YES; + AnimatedTransitioning *controller = [[AnimatedTransitioning alloc] init]; + [controller setReverse:NO]; return controller; } - (id )animationControllerForDismissedController:(UIViewController *)dismissed { -//I will fix it later. -// AnimatedTransitioning *controller = [[AnimatedTransitioning alloc]init]; -// controller.isPresenting = NO; -// return controller; - return nil; + AnimatedTransitioning *controller = [[AnimatedTransitioning alloc] init]; + [controller setReverse:YES]; + return controller; } - (id )interactionControllerForPresentation:(id )animator {