Comments (7)
I have toyed around with that idea but haven't had a chance to implement it yet,... I'll definitely add this as a high priority to-do!
Most likely I'll end up with a system similar to dequeue'ing a tableViewCell where it just looks whether it already has an instance of said viewController and uses it before requesting a new one. Shouldn't be too hard but I wanna make sure to do it right :-)
from pkrevealcontroller.
That would be awesome, i'm integrating this into some apps that are going to be pretty heavily used and I think this will be a big improvement for the users. :-)
from pkrevealcontroller.
+1, this would be a VERY nice addition
from pkrevealcontroller.
You can easily do this already without any modifications to ZUUIRevealController.
A tab bar controller manages the buttons/actions that swap the views so it has to keep the controllers around. When you use a ZUUIRevealController to implement a menu, the controller that implements the menu is the one that swaps the views by calling setFrontViewController.
Instead of creating a new controller every time like the sample app does you can keep the controllers around and manage their lifetimes any way you like. Swap them out with existing instances and their states will not have changed, or if memory usage is an issue you can create new ones every time and set their state to the last known state.
from pkrevealcontroller.
How very correct you are sir...
from pkrevealcontroller.
To solve this problem in the Demo, I made properties for each view in the AppDelegate, and defined a shortcut to the AppDelegate
#define sharedAppDelegate (AppDelegate *) [[UIApplication sharedApplication] delegate]
@class MapViewController;
@class FrontViewController;
@class RevealController;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) RevealController *viewController;
@property (strong, nonatomic) FrontViewController *frontViewController;
@property (strong, nonatomic) MapViewController *mapViewController;
@end
Now import, synthesize. alloc and init these in the .m
#import "RevealController.h"
#import "FrontViewController.h"
#import "RearViewController.h"
#import "MapViewController.h"
@implementation AppDelegate
@synthesize window = _window;
@synthesize viewController = _viewController;
@synthesize mapViewController = _mapViewController;
@synthesize frontViewController = _frontViewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
UIWindow *window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window = window;
self.frontViewController = [[FrontViewController alloc] init];
self.mapViewController = [[MapViewController alloc] init];
RearViewController *rearViewController = [[RearViewController alloc] init];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:self.frontViewController];
In the RearViewController.m I changed didSelectRowAtIndexPath like so..
else if (indexPath.row == 1)
{
// Now let's see if we're not attempting to swap the current frontViewController for a new instance of ITSELF, which'd be highly redundant.
if ([revealController.frontViewController isKindOfClass:[UINavigationController class]] && ![((UINavigationController *)revealController.frontViewController).topViewController isKindOfClass:[MapViewController class]])
{
MapViewController *mapViewController = (MapViewController*)[sharedAppDelegate mapViewController];
UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:mapViewController];
[revealController setFrontViewController:navigationController animated:NO];
[mapViewController reAddGesture];
}
You can see a 'reAddGesture' method there, since for some reason the gestures don't work unless I re-add them. So in the MapViewController I put this method:
-(void)reAddGesture
{
[self.navigationController.navigationBar removeGestureRecognizer:nil];
UIPanGestureRecognizer *navigationBarPanGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self.navigationController.parentViewController action:@selector(revealGesture:)];
[self.navigationController.navigationBar addGestureRecognizer:navigationBarPanGestureRecognizer];
}
from pkrevealcontroller.
Is this feature inside the 1.0b2 tag? If so, do I have to explicitly activate it?
from pkrevealcontroller.
Related Issues (20)
- Limit the pan gesture in the main view
- PKRevealController doesn't play well with unwind segues
- UIScreenEdgePanGestureRecognizer instead of UIPanGestureRecognizer
- LeftView and CenterView Controller both vertical scrollable
- Show left or right UIViewController programmatically. HOT 1
- revealController:willChangeToState firing too late
- It will flash in the first time HOT 1
- leftBarButtonItem
- How to do ajustment of leftview to statusbar in IOS8?
- Disable pan gesture on front VC when showing VCs from side HOT 1
- Difference to UISplitViewController HOT 1
- Panning doesn't work HOT 1
- Create new tag v2.0.7 for CocoaPod
- 2:Issues as need quick assistance
- Add tabbar
- Crashes When Attempting to Present Side View Multiple Times
- setFrontViewController deprecated, no replacement HOT 1
- PKReveal dead? HOT 3
- `prefersStatusBarHidden` is not called in the FrontViewController
- ViewController lost reference when push notification was being clicked and when the app was in background too
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 pkrevealcontroller.