0
votes

I want to use a custom segue from my destination view controller back to the source view controller using the "Back" button in the NavBar. Is this possible? I have not been able to find an answer anywhere.

So far, I connected a custom segue from the destination view controller back to the source view controller and add the code below. However, the back-button does not trigger my custom segue.

-(void)perform
{

    UIViewController *sourceViewController = (UIViewController*)[self sourceViewController];
    UIViewController *destinationController = (UIViewController*)[self destinationViewController];

    CATransition* transition = [CATransition animation];
    transition.type = kCATransitionMoveIn;
    transition.subtype = kCATransitionFromTop;
    transition.duration = 0.5;

    [sourceViewController.navigationController.view.layer addAnimation:transition forKey:kCATransition];
    [sourceViewController.navigationController pushViewController:destinationController animated:NO];
}
1
It's good that it doesn't work, because a "back" segue needs to pop not push. - matt

1 Answers

1
votes

The way to customize the transition back from a pushed view controller as it is popped from the navigation stack is with a custom transition, a new feature in iOS 7. (Prior to iOS 7 this is basically impossible.)