diff --git a/CustomTransitionExample/CustomTransitionExample/AnimatedTransitioning.m b/CustomTransitionExample/CustomTransitionExample/AnimatedTransitioning.m index c346517..e38c794 100755 --- a/CustomTransitionExample/CustomTransitionExample/AnimatedTransitioning.m +++ b/CustomTransitionExample/CustomTransitionExample/AnimatedTransitioning.m @@ -25,20 +25,33 @@ - (void)animateTransition:(id )transitionC UIView *inView = [transitionContext containerView]; SecondViewController *toVC = (SecondViewController *)[transitionContext viewControllerForKey:UITransitionContextToViewControllerKey]; MainViewController *fromVC = (MainViewController *)[transitionContext viewControllerForKey:UITransitionContextFromViewControllerKey]; - - [inView 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) { - [transitionContext completeTransition:YES]; - }]; + if (self.isPresenting) { + [inView 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) { + [transitionContext completeTransition:YES]; + }]; + }else{ + CGRect screenRect = [[UIScreen mainScreen] bounds]; + [UIView animateWithDuration:0.25f + animations:^{ + + [fromVC.view setFrame:CGRectMake(screenRect.size.width, 0, fromVC.view.frame.size.width, fromVC.view.frame.size.height)]; + } + completion:^(BOOL finished) { + [transitionContext completeTransition:YES]; + [fromVC.view removeFromSuperview]; + }]; + + } } diff --git a/CustomTransitionExample/CustomTransitionExample/TransitionDelegate.m b/CustomTransitionExample/CustomTransitionExample/TransitionDelegate.m index 23c31b9..959128f 100755 --- a/CustomTransitionExample/CustomTransitionExample/TransitionDelegate.m +++ b/CustomTransitionExample/CustomTransitionExample/TransitionDelegate.m @@ -24,10 +24,9 @@ @implementation TransitionDelegate - (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.isPresenting = NO; + return controller; } - (id )interactionControllerForPresentation:(id )animator {