diff --git a/SlideMenu/Source/SlideNavigationController.h b/SlideMenu/Source/SlideNavigationController.h index 0d66769..ef8db6a 100644 --- a/SlideMenu/Source/SlideNavigationController.h +++ b/SlideMenu/Source/SlideNavigationController.h @@ -22,6 +22,7 @@ typedef enum{ @interface SlideNavigationController : UINavigationController +@property (nonatomic, assign) BOOL avoidSwitchingToSameClassViewController; @property (nonatomic, strong) UIViewController *righMenu; @property (nonatomic, strong) UIViewController *leftMenu; @property (nonatomic, strong) UIBarButtonItem *leftbarButtonItem; diff --git a/SlideMenu/Source/SlideNavigationController.m b/SlideMenu/Source/SlideNavigationController.m index feee0dc..078ea4c 100644 --- a/SlideMenu/Source/SlideNavigationController.m +++ b/SlideMenu/Source/SlideNavigationController.m @@ -64,6 +64,7 @@ static SlideNavigationController *singletonInstance; - (void)setup { + self.avoidSwitchingToSameClassViewController = YES; singletonInstance = self; self.delegate = self; @@ -81,6 +82,12 @@ static SlideNavigationController *singletonInstance; - (void)switchViewController:(UIViewController *)viewController withCompletion:(void (^)())completion { + if (self.avoidSwitchingToSameClassViewController && [self.topViewController isKindOfClass:viewController.class]) + { + [self closeMenuWithCompletion:completion]; + return; + } + __block CGRect rect = self.view.frame; if ([self isMenuOpen])