From bb24e0f72fdf409a3d140f3774cc15e2d2928cb6 Mon Sep 17 00:00:00 2001 From: RajendrasinhParmar Date: Sun, 6 Sep 2015 14:54:37 +0530 Subject: [PATCH 1/3] Solve dismiss animation issue Updated code to dismiss the popup view controller with desired animation --- .../AnimatedTransitioning.m | 41 ++++++++++++------- .../TransitionDelegate.m | 7 ++-- 2 files changed, 30 insertions(+), 18 deletions(-) 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 { From c0b8d453fd6fd7c92066640a0baaa622c1152386 Mon Sep 17 00:00:00 2001 From: RajendrasinhParmar Date: Sun, 6 Sep 2015 15:00:11 +0530 Subject: [PATCH 2/3] update gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..544ab83 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +CustomTransitionExample/CustomTransitionExample.xcodeproj/project.xcworkspace/xcuserdata/jayMataji.xcuserdatad/UserInterfaceState.xcuserstate From cba3526e470c95f13873e66574e97c1bf98085e5 Mon Sep 17 00:00:00 2001 From: RajendrasinhParmar Date: Sun, 6 Sep 2015 15:05:20 +0530 Subject: [PATCH 3/3] Revert "update gitignore" This reverts commit c0b8d453fd6fd7c92066640a0baaa622c1152386. --- .gitignore | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 .gitignore diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 544ab83..0000000 --- a/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ - -CustomTransitionExample/CustomTransitionExample.xcodeproj/project.xcworkspace/xcuserdata/jayMataji.xcuserdatad/UserInterfaceState.xcuserstate