Giter VIP home page Giter VIP logo

Comments (7)

pkluz avatar pkluz commented on August 18, 2024

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.

sammio2 avatar sammio2 commented on August 18, 2024

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.

anthonywebb avatar anthonywebb commented on August 18, 2024

+1, this would be a VERY nice addition

from pkrevealcontroller.

ianiv avatar ianiv commented on August 18, 2024

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.

sammio2 avatar sammio2 commented on August 18, 2024

How very correct you are sir...

from pkrevealcontroller.

cannyboy avatar cannyboy commented on August 18, 2024

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.

mickeyckm avatar mickeyckm commented on August 18, 2024

Is this feature inside the 1.0b2 tag? If so, do I have to explicitly activate it?

from pkrevealcontroller.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.