Create a gist now

Instantly share code, notes, and snippets.

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