title: Custom segue push like with back button
body: <p>I’m trying to build my custom segue, similar in behavior to standard Push segue, but in my case I want to use custom buttons to switch between screens (no tab bars will fit to this app, any modal segue is no good either). The main screen is a custom graphics and the screen to segue to is a map. User to choose the point on the map, hit done and come back to the main screen with it’s coordinates. 
  I’m trying to connect ViewControllers with custom segue. </p>
  
  <p>I research a lot of solution across the Internet and found one, which can fit, but the code is scatter all around ViewControllers and AppDelegate (I’m not certain if Apple will accept it). I’m trying put whole code to a CustomSegue.m /h. The success is partial because using technique (below) it segues to the second ViewControler but I can’t figure out how to dismiss the second and come back to main screen. I tried various techniques but when I run it the compiler terminates app with bunch of errors. Neither errors nor warnings before building and running. I also tried to dismiss it with a button using [self dismissModalViewControllerAnimated:YES]; or [self dismissViewControllerAnimated:YES completion:nil]; they work when I try modal segues but with my code with bad result. </p>
  
  <p>Does anyone have a suggestion on a neat way of doing this. I’m stack on this problem for the last couple of days. I see that kind of segues transitions in a lot apps so it seems to be quite popular, easy solution. I’m not much experienced in Xcode only couple of mo. 
  This is my custom segue (with QuartzCore animation). </p>
  
  <pre><code>#import "CustomTabBarSegue.h"
  
  @implementation CustomTabBarSegue
  
  
   -(void)perform {
      UIViewController *src = (UIViewController*)[self sourceViewController];
      UIViewController *dst = (UIViewController*)[self destinationViewController];
  
      UIView *currentView = src.view;
      UIView *theWindow = [currentView superview];
      UIView *newView = dst.view;
      [theWindow addSubview:newView];
  
      CATransition *transition = [CATransition animation];
  
      transition.delegate = self;
      transition.duration = 1;
  
      transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
      transition.type = kCATransitionMoveIn; 
      transition.subtype = kCATransitionFromRight;
  
  
      [[theWindow layer] addAnimation:transition forKey:@"MySegue"];
   }
  
  @end
  </code></pre>
  
  <p>Below is code for my button back from destinationVC. (doesn't work)</p>
  
  <pre><code>- (IBAction)dismiss:(id)sender 
  </code></pre>
  
  <p>{</p>
  
  <pre><code>[self dismissViewControllerAnimated:YES completion:^() {
      [self performSegueWithIdentifier:@"MySegue" sender:self];
  }];
  </code></pre>
  
  <p>}</p>