Skip to content

Instantly share code, notes, and snippets.

@mikeabdullah
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mikeabdullah/c01290c64a959418ebd0 to your computer and use it in GitHub Desktop.
Save mikeabdullah/c01290c64a959418ebd0 to your computer and use it in GitHub Desktop.
Modal segue class
@interface ModalSegue : UIStoryboardSegue
@property(nonatomic, readonly) UINavigationController *navigationController;
@end
@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
animated:YES
completion:NULL];
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment