Comments (7)
You can do that by registering the navigationController interactiveGestureRecognizer to the open side menu selector.
from twtsidemenuviewcontroller.
+1
from twtsidemenuviewcontroller.
Please have a look at #30.
from twtsidemenuviewcontroller.
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.
from twtsidemenuviewcontroller.
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.
from twtsidemenuviewcontroller.
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.
-(BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer{
if (gestureRecognizer==self.navigationController.interactivePopGestureRecognizer) {
[[NSNotificationCenter defaultCenter] postNotificationName:@"popBack" object:nil];
}
return YES;
}
-(void)viewWillDisappear:(BOOL)animated{
[super viewWillDisappear:animated];
[[NSNotificationCenter defaultCenter]removeObserver:self name:@"popBack" object:nil];
}
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(openMenu) name:@"popBack" object:nil];
}
-(void)viewDidLoad{
self.navigationController.interactivePopGestureRecognizer.delegate=self;
}
In your other VC that will be pushed onto the UINavigationController stack,
-(void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(anotherMethodThatPopstoRootVC) name:@"popBack" object:nil];
}
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.
from twtsidemenuviewcontroller.
I found RESideMenu that supports pan gesture
from twtsidemenuviewcontroller.
Related Issues (20)
- Change side menu controller on the fly?
- Installing via CocoaPods HOT 4
- Right SideMenu HOT 1
- iPad Landscape issue HOT 2
- UIViewController View Events limitation of sidemenuviewcontroller?
- Misaligned frame when appearing in landscape
- UINavigationController in menuViewController overlaps status bar HOT 9
- UISplitViewController HOT 1
- SideMenu on all ViewControllers
- iOS 8 support HOT 1
- Too many calls to addChildViewController
- wrong initial menuViewController transform ?
- I can see my side menu in the background
- Tap status bar no scrolling up
- How to open the respected view controller,when the push notification comes in TWTSIdeMenu ViewController
- Support for Arabic language
- Conflicting return type in implementation of 'supportedInterfaceOrientations': 'UIInterfaceOrientationMask' HOT 2
- Storyboards....scrolling too! HOT 19
- Cocoa Pods ARC Bug HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from twtsidemenuviewcontroller.