0

This is mouli, I'm implementing a custom segue for pushing (with animation) from firstview to second view, its work fine. but iam not getting back from secondview to firstview with same animation. Here the first screen appears with out animation. please give some suggestion. Thanks in advance. following is my code for push from first to second.

    UIViewController *sourceViewController = [UIApplication sharedApplication].delegate.window.rootViewController;
    NSLog(@"%@",sourceViewController);

    sourceViewController.modalPresentationStyle = UIModalPresentationCurrentContext;
    UIViewController *destinationController = (UIViewController*)[self destinationViewController];
    NSLog(@"%@",destinationController);

    CATransition* transition = [CATransition animation];
    transition.duration = 0.6;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = kCATransitionPush; //kCATransitionMoveIn; //, kCATransitionPush, kCATransitionReveal, kCATransitionFade
    transition.subtype = kCATransitionFromRight; //kCATransitionFromLeft, kCATransitionFromRight, kCATransitionFromTop, kCATransitionFromBottom

    [destinationController.view.layer addAnimation:transition forKey:kCATransition];
    [sourceViewController presentViewController:destinationController animated:NO completion:nil];
raurora
  • 3,623
  • 1
  • 22
  • 29
user2823044
  • 315
  • 2
  • 5
  • 14

1 Answers1

0

Do the dismiss in opposite way, since your are doing a custom animation other that the provided one, it doesn't remember the animation of presentation. So while you are dismissing you need to apply the opposite custom animation too.

I would suggest you to create a Category for animations and use them in the whole project easily..

iphonic
  • 12,615
  • 7
  • 60
  • 107