Skip to content

Instantly share code, notes, and snippets.

@kcharwood
Last active January 9, 2018 13:18
Show Gist options
  • Save kcharwood/9123820 to your computer and use it in GitHub Desktop.
Save kcharwood/9123820 to your computer and use it in GitHub Desktop.
#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