Instantly share code, notes, and snippets.

@mikeabdullah mikeabdullah/ModalSegue.h
Last active Aug 29, 2015

What would you like to do?
Modal segue class
@interface ModalSegue : UIStoryboardSegue
@property(nonatomic, readonly) UINavigationController *navigationController;
@implementation ModalSegue
- (instancetype)initWithIdentifier:(NSString *)identifier
source:(UIViewController *)source
destination:(UIViewController *)destination {
if (self = [super initWithIdentifier:identifier source:source destination:destination]) {
// Package the destination VC up into a nav controller
_navigationController = [[UINavigationController alloc] initWithRootViewController:destination];
_navigationController.modalPresentationStyle = destination.modalPresentationStyle;
return self;
- (void)perform {
// Present the navigation controller, rather than presenting the destination VC directly
[self.sourceViewController presentViewController:self.navigationController
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment