handsomecode / InteractiveSideMenu

iOS Interactive Side Menu written in Swift.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to disable Swipe from left -> Show menu gesture?

epitonium opened this issue · comments

I need to show the menu only by clicking on the showMenuButton. Currently the user also can swipe and the menu will appear. How can i disable this functionality?

Hi @epitonium,

There is no option to disable swipe using InteractiveSideMenu public methods.

To do it you should load sources and remove these lines in viewDidLoad of MenuContainerViewController:

let screenEdgePanRecognizer = UIScreenEdgePanGestureRecognizer(
target: navigationMenuTransitionDelegate.interactiveTransition,
action: #selector(MenuInteractiveTransition.handlePanPresentation(recognizer:)))
screenEdgePanRecognizer.edges = .left
view.addGestureRecognizer(screenEdgePanRecognizer)

It will disable swipe on menu opening.

If you also want to disable swipe on menu closing you should commit this line in func finishTransition(currentPercentComplete) of MenuAnimator class:

if let panRecognizer = self.panRecognizer {
     contentSnapshotView.addGestureRecognizer(panRecognizer)
}

Thank you for your question, we'll think about implementing this option in a future release.

commented

Thanks for this. Was having an issue where my table view moves up, hindering my custom header section.

Enabling and disabling the swipe is a great feature.

When is modal is displayed that must be resolved, right now the user can just swipe to the menu to escape.

EDIT, actually I can disable from the HostViewController: MenuContainerViewController.

        if let gestures = view.gestureRecognizers {
            for gesture in gestures {
                gesture.isEnabled = false
            }
        }

But it must be disabled from the viewDidLoad(), and I havn't figured out yet how to just re-enable swipes.

Update: Couldn't get re-enabling to work. For now decided it's best to just disable this way.