diff --git a/SlideMenu/Source/SlideNavigationController.h b/SlideMenu/Source/SlideNavigationController.h index b64701b..a4632b7 100644 --- a/SlideMenu/Source/SlideNavigationController.h +++ b/SlideMenu/Source/SlideNavigationController.h @@ -71,6 +71,7 @@ extern NSString *const SlideNavigationControllerDidReveal; - (void)bounceMenu:(Menu)menu withCompletion:(void (^)())completion; - (void)openMenu:(Menu)menu withCompletion:(void (^)())completion; - (void)closeMenuWithCompletion:(void (^)())completion; +- (void)removeAllMenuFromSuperview; - (void)toggleLeftMenu; - (void)toggleRightMenu; - (BOOL)isMenuOpen; diff --git a/SlideMenu/Source/SlideNavigationController.m b/SlideMenu/Source/SlideNavigationController.m index d7409a6..1c2f859 100644 --- a/SlideMenu/Source/SlideNavigationController.m +++ b/SlideMenu/Source/SlideNavigationController.m @@ -608,6 +608,21 @@ - (void)prepareMenuForReveal:(Menu)menu [self.menuRevealAnimator prepareMenuForAnimation:menu]; } +- (void)removeAllMenuFromSuperview +{ + if (self.lastRevealedMenu == MenuLeft){ + UIViewController *menuViewController = self.leftMenu; + [menuViewController.view removeFromSuperview]; + } else if (self.lastRevealedMenu == MenuRight){ + UIViewController *menuViewController = self.rightMenu; + [menuViewController.view removeFromSuperview]; + } + + // Set lastRevealedMenu to Nil so we insert the Subview when prepareMenuForReveal is subsequently called + self.lastRevealedMenu = Nil; + return; +} + - (CGFloat)horizontalLocation { CGRect rect = self.view.frame;