Last active
January 9, 2018 13:18
-
-
Save kcharwood/9123820 to your computer and use it in GitHub Desktop.
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
#import "MMNavigationController.h" | |
#import <MMDrawerController/UIViewController+MMDrawerController.h> | |
@interface MMNavigationController () | |
@end | |
@implementation MMNavigationController | |
- (id)initWithRootViewController:(UIViewController *)rootViewController{ | |
self = [super initWithRootViewController:rootViewController]; | |
if (self) { | |
[self setOpenGestureModeForRootView:MMOpenDrawerGestureModeBezelPanningCenterView|MMOpenDrawerGestureModePanningNavigationBar]; | |
[self setOpenGestureModeForNonRootView:MMDrawerSideNone]; | |
} | |
return self; | |
} | |
- (void)setViewControllers:(NSArray *)viewControllers { | |
[super setViewControllers:viewControllers]; | |
[self setOpenGestureModeForCurrentState]; | |
} | |
- (void)setViewControllers:(NSArray *)viewControllers animated:(BOOL)animated { | |
[super setViewControllers:viewControllers animated:animated]; | |
[self setOpenGestureModeForCurrentState]; | |
} | |
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated { | |
[super pushViewController:viewController animated:animated]; | |
[self setOpenGestureModeForCurrentState]; | |
} | |
- (UIViewController *)popViewControllerAnimated:(BOOL)animated { | |
UIViewController *viewController = [super popViewControllerAnimated:animated]; | |
[self setOpenGestureModeForCurrentState]; | |
return viewController; | |
} | |
- (NSArray *)popToRootViewControllerAnimated:(BOOL)animated { | |
return [super popToRootViewControllerAnimated:animated]; | |
} | |
- (void)setOpenGestureModeForCurrentState { | |
if ([self.viewControllers count] == 1) { | |
[self.mm_drawerController setOpenDrawerGestureModeMask:self.openGestureModeForRootView]; | |
} | |
else { | |
[self.mm_drawerController setOpenDrawerGestureModeMask:self.openGestureModeForNonRootView]; | |
} | |
} | |
- (void)didMoveToParentViewController:(UIViewController *)parent { | |
if ([parent isKindOfClass:[MMDrawerController class]]) { | |
[self setOpenGestureModeForCurrentState]; | |
} | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment