How to create custom modal segue in 4.2 Xcode using storyboard [closed]

This custom seque pops back to the root of a navigation stack. Use a normal pop instead of “popToViewController” if you want to go back one level. I just love the name of this method.

header:

#import <UIKit/UIKit.h>

@interface FlipTopPopToRoot : UIStoryboardSegue

@end

implementation:

#import "FlipTopPopToRoot.h"

@implementation FlipTopPopToRoot

- (void) perform {

UIViewController *src = (UIViewController *) self.sourceViewController;
[UIView transitionWithView:src.navigationController.view duration:0.5
                   options:UIViewAnimationOptionTransitionFlipFromTop
                animations:^{
                    [src.navigationController popToViewController:[src.navigationController.viewControllers objectAtIndex:0] animated:NO];;
                }
                completion:NULL];
}

@end

Leave a Comment