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?
@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.
Hmm it didn't seem to work.
I tried this:
SideMenuManager.menuRightSwipeToDismissGesture?.enabled = false
SideMenuManager.menuLeftSwipeToDismissGesture?.enabled = false
and even on this on both the side viewcontroller and the main viewcontroller
if let swipe1 = SideMenuManager.menuRightSwipeToDismissGesture, swipe2 = SideMenuManager.menuLeftSwipeToDismissGesture {
view.removeGestureRecognizer(swipe1)
view.removeGestureRecognizer(swipe2)
}
The swiping still seems to occur.
You can't disable it if you set the reference to nil. Also I think the gesture is recreated every time the menu is exposed. Take a look at the code to understand more closely.
Thanks for the quick replies.
if let blocksviewDidAppear and they seem to be properly disabled. I'm taking a look at the code right now and I can't seem to figure out why the gestures are still being fired.
Try removing them in viewDidAppear if disabling isn't working.
I created a test project here. I think either this is a bug or I'm obviously missing something.
https://github.com/mbalex99/swipesidemenuissue
The swipe still occurs.
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.
https://github.com/mbalex99/swipesidemenuissue
I pushed those changes and added some explicit code.
Okay I did what you said, doesn't seem to be working. I checked and the gestures are never nil at viewDidLoad or viewWillAppear or viewWillAppear
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! 馃憤
Disabling them in viewWillAppear of the menu is working for me.
However, it's important to note that it's disabling those gestures on the menu itself, but _not_ on the main screen that's partially displayed. The main screen has a transparent view over it to take taps and swipes to hide the menu and prevent the partial screen from being interacted with. The gestures were separated this way so that they could be disabled on the menu in case of special menu gestures but still make it easy to dismiss the menu. As such, this is not a bug, but by design.
As a general note, my goal with this library was to hit the 90%+ use case, and I think it's accomplished that. If you would like to contribute to this library, I'm all for it! I haven't heard of a compelling use case for turning off the swiping gestures from anyone else yet.
If you want to contribute, I would suggest taking a look at line 310 of SideMenuTransition. These are the gestures you would like to disable, but they are not exposed. There would either need to be a boolean added to SideMenuManager to turn off swipe gestures at large, or a getter method to expose those gestures to be disabled.
Are you using the same code from my project? I have the code in the MenuViewController at viewWillAppear and you can still swipe to dismiss.
Ah I see what you did there with the transparent overlay, but since the SideMenuManager is managing a singleton instance shouldn't the disable/enable of the gesture recognizers still disable it for all instances?
I added two lines of code to disable gestures to the example project in the repo and it worked as expected.
A challenge with the design is that a storyboard will create a new instance of a SideMenu via segues, vs. setting up the right and left menus on first launch. Since a new menu instance can be created at any time, many of the commands related to menus are not singleton oriented, but hooked to the singular instance of that menu when its assigned to the manager. It could be re-architected to move the gesture from menu to menu or use a master boolean to control behavior, but again in light of the 90%+ use cases there was no need for that level of effort.
Okay! I created a fork and a pull request!
@mbalex99 I don't see any pull requests.
@mbalex99 disregard just appeared.
I would also like to see this feature implemented. Looking forward to the pull request merged.
its here 馃憤
sideMenuNavigationController.enableSwipeToDismissGesture = false
Most helpful comment
I would also like to see this feature implemented. Looking forward to the pull request merged.