@@ -107,11 +107,6 @@ - (void)viewWillLayoutSubviews
107107{
108108 [super viewWillLayoutSubviews ];
109109
110- // When menu open we disable user interaction
111- // When rotates we want to make sure that userInteraction is enabled again
112- self.topViewController .view .userInteractionEnabled = YES ;
113- [self .view removeGestureRecognizer: self .tapRecognizer];
114-
115110 // Update shadow size
116111 self.view .layer .shadowPath = [UIBezierPath bezierPathWithRect: self .view.bounds].CGPath ;
117112}
@@ -120,6 +115,10 @@ - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrie
120115{
121116 [super willRotateToInterfaceOrientation: toInterfaceOrientation duration: duration];
122117
118+ // When menu open we disable user interaction
119+ // When rotates we want to make sure that userInteraction is enabled again
120+ [self enableTapGestureToCloseMenu: NO ];
121+
123122 // Avoid an ugnly shadow in background while rotating
124123 self.view .layer .shadowOpacity = 0 ;
125124}
@@ -263,6 +262,20 @@ - (NSArray *)popToViewController:(UIViewController *)viewController animated:(BO
263262
264263#pragma mark - Private Methods -
265264
265+ - (void )enableTapGestureToCloseMenu : (BOOL )enable
266+ {
267+ if (enable)
268+ {
269+ self.topViewController .view .userInteractionEnabled = NO ;
270+ [self .view addGestureRecognizer: self .tapRecognizer];
271+ }
272+ else
273+ {
274+ self.topViewController .view .userInteractionEnabled = YES ;
275+ [self .view removeGestureRecognizer: self .tapRecognizer];
276+ }
277+ }
278+
266279- (void )toggleMenu : (Menu)menu withCompletion : (void (^)())completion
267280{
268281 if ([self isMenuOpen ])
@@ -313,8 +326,7 @@ - (BOOL)shouldDisplayMenu:(Menu)menu forViewController:(UIViewController *)vc
313326
314327- (void )openMenu : (Menu)menu withDuration : (float )duration andCompletion : (void (^)())completion
315328{
316- self.topViewController .view .userInteractionEnabled = NO ;
317- [self .view addGestureRecognizer: self .tapRecognizer];
329+ [self enableTapGestureToCloseMenu: YES ];
318330
319331 [self prepareMenuForReveal: menu forcePrepare: NO ];
320332
@@ -335,8 +347,7 @@ - (void)openMenu:(Menu)menu withDuration:(float)duration andCompletion:(void (^)
335347
336348- (void )closeMenuWithDuration : (float )duration andCompletion : (void (^)())completion
337349{
338- self.topViewController .view .userInteractionEnabled = YES ;
339- [self .view removeGestureRecognizer: self .tapRecognizer];
350+ [self enableTapGestureToCloseMenu: NO ];
340351
341352 [UIView animateWithDuration: duration
342353 delay: 0
0 commit comments