0

I am trying to implement a 'Cover Horizontal' transition for my Storyboard's UIViewControllers. A simple slide right to left and back again. First I am surprised that this is not an option in Interface Builder. Doesn't everybody need this or am I missing something? I created a Custom-Segue and added a Sliding Transition.

#import "SlideLeftCustomSegue.h"

@implementation SlideLeftCustomSegue

- (void)perform{

    UIViewController *srcViewController = (UIViewController *) self.sourceViewController;
    UIViewController *destViewController = (UIViewController *) self.destinationViewController;

    CATransition *transition = [CATransition animation];
    transition.duration = 0.3;
    transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
    transition.type = kCATransitionPush;
    transition.subtype = kCATransitionFromRight;
    [srcViewController.view.window.layer addAnimation:transition forKey:nil];

    [srcViewController presentViewController:destViewController animated:NO completion:nil];
}

@end

That all works fine in the push direction but how do I get the same effect for the dismiss? It all seems a bit difficult for a very simple transition. Again I feel I am missing something..... Any help would be great.

Sergey Kalinichenko
  • 675,664
  • 71
  • 998
  • 1,399
Alan
  • 796
  • 9
  • 26
  • 1
    Use the force, Alan... http://stackoverflow.com/a/15839298/2700842 – Nick Terry Sep 23 '13 at 18:52
  • Ok I have spent a few hours looking at all the information about dismissing segues, but I still cannot figure out where I should add my animation to slide right. Can I somehow use a custom segue for the dismiss? Or where do I add my dismiss animation? – Alan Sep 23 '13 at 21:04
  • The docs (https://developer.apple.com/library/ios/documentation/uikit/reference/UIViewController_Class/Reference/Reference.html#//apple_ref/doc/uid/TP40006926-CH3-SW118) have the `-(UIStoryboardSegue *)segueForUnwindingToViewController:(UIViewController *)toViewController fromViewController:(UIViewController *)fromViewController identifier:(NSString *)identifier` method you can use (put your animation code here). It will be called, then the `unwindToSegue:` method will be called. That should work. Wire up the unwind method as the link posted before directs. – Nick Terry Sep 24 '13 at 01:33

0 Answers0