-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Why not add gestures to control the open and close? #7
Comments
You can do that by registering the navigationController interactiveGestureRecognizer to the open side menu selector. |
+1 |
Please have a look at #30. |
Be careful if you do this as it interferes with the interactivePopGestureRecognizer in the other viewcontroller. Meaning, if you try the back swipe gesture to pop the other viewcontrollers, it will open the side menu instead, screwing up everything. A crude way to work around this is to delegate what the interactivePopGestureRecognizer should do in every view controller manually. Meaning, in the mainViewController, your interactivePopGestureRecognizer should open the menu. In the VC that are pushed onto the mainVC, the interactivePopGestureRecognizer carry out the action [self.navigationController popToRootViewControllerAnimated:YES]; You can do this by making the interactivePopGestureRecognizer post certain types of notifications and making every VC register to the NSNotificationCenter when it first comes onto the scene. You also must remove the observer to these notifications right before you seque. Not doing this will cause a major bug when the user push and pop VC very fast, the app will turn completely blank. A really huge headache to implement something so simple. |
Thank you very much for pointing this out. I agree that there is a problem with this method if the other view controller is an instance of UINavigationController. However, in the sample project, the other view controller is an instance of UITableViewController, which, as far as I can see, does not use an interactive gesture recognizer. Thus, for the sample project, my simple changes should be fine. Please correct me if I am wrong. Maybe one should add a navigation view controller to the sample project and give a best practice approach on how to implement these gestures. This should at least reduce headaches for anyone using this side menu controller. |
It's really dependent on your project. For mine, the mainVC is a UITableVC. The next VC that could get push segue are UIViewVC and UITableViewVC. You really have to worry about this if you use UINavigationController because the gesture will conflict. To implement this, here's a sample code.
} In your other VC that will be pushed onto the UINavigationController stack, Also, don't try to get around this by making your interactivePopGestureRecognizer.delegate = nil when you segue. It just won't work and your menu will still open whenever users pop the VC. |
I found RESideMenu that supports pan gesture |
Hi! @vokalinteractive
I think will improve the user experience
The text was updated successfully, but these errors were encountered: