SideMenu: Setting Swipe Gestures to Nil Doesn't Disable Swipe Gesture

        conversationsViewController.conversationsViewControllerDelegate = self
        SideMenuManager.menuLeftNavigationController = conversationsViewController
        SideMenuManager.menuPresentMode = .ViewSlideInOut
        SideMenuManager.menuFadeStatusBar = false
        SideMenuManager.menuWidth = max(round(min(UIScreen.mainScreen().bounds.width, UIScreen.mainScreen().bounds.height) * 0.85), 240)
        SideMenuManager.menuShadowOpacity = 0
        SideMenuManager.menuRightSwipeToDismissGesture = nil
        SideMenuManager.menuLeftSwipeToDismissGesture = nil
        SideMenuManager.menuAnimationPresentDuration = 0.25
        SideMenuManager.menuAnimationDismissDuration = 0.25

As you can see I’ve set both swipe gestures to nil however, I’m still able to swipe and dismiss the controller. What am I doing wrong?

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 17 (15 by maintainers)

Most upvoted comments

I would also like to see this feature implemented. Looking forward to the pull request merged.

So yeah I’ve tried everything and it’s still swiping. If it’s this difficult or unintuitive wouldn’t that be respectable to say it’s a bug by now?

Again thanks for swift support! 👍

There is still more to try before calling this a bug.

Your code has you disabling it in viewDidLoad. My guess is that inspecting the gestures at that point would reveal they are nil, so that won’t work.

In menuPressed you have it disabling the gestures. Again inspection may reveal that the gestures at that point are still nil since the menu hasn’t revealed yet.

Instead, in MenuViewController, try disabling or removing the gestures on viewWillAppear.

@mbalex99, dig a little deeper! Both menuRightSwipeToDismissGesture and menuRightSwipeToDismissGesture are weak references, so that should be a clue that setting to nil won’t release them.

You need to either remove the gestures from the view or disable them. Read up on UIGestureRecognizers for more info.