Last active
August 29, 2015 14:09
-
-
Save mikeabdullah/c01290c64a959418ebd0 to your computer and use it in GitHub Desktop.
Modal segue class
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@interface ModalSegue : UIStoryboardSegue | |
@property(nonatomic, readonly) UINavigationController *navigationController; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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