Search code examples
iosobjective-cviewdeck

iOS ViewDeck remove overall titlebar


I'm currently working on a project which involves ViewDeck by Inferis.

I'm looking to create the Facebook style menu interface. However i can't seem to manage to keep the titlebar local instead of globally for the deckController.

So basically, i'm having a rootviewcontroller which pushes a login view controller on stack. Nothing fancy. but when i'm logged in, it needs to push the IIViewDeckController on stack, but without all the navigation bars

How it codes:

neighbourhoodViewController *nextViewController = [[neighbourhoodViewController alloc] initWithNibName:@"neighbourhoodViewController" bundle:nil];
menuViewController *leftViewController = [[menuViewController alloc]  initWithNibName:@"menuViewController" bundle:nil];
IIViewDeckController* deckController =  [[IIViewDeckController alloc] nitWithCenterViewController:nextViewController leftViewController:leftViewController];
deckController.leftSize = 100.0f;
[self.navigationController pushViewController:deckController animated:YES];

The outcomming is the following screenshot: http://s15.postimg.org/pli8zk53f/Schermafbeelding_2013_05_22_om_15_00_43.png

As you can see the menu is "in the viewcontroller" but it needs to be outside, so the navigation bar should slide right together with the middle TableViewController

I've tried to hide all the navigationbars but nothing seems to work. Also i've tried launching it from app delegate, since that's in the example. It works. However, i need to run it from the Login View Controller.

Thnx


Solution

  • You need to rearrange your structure slightly.

    Make the IIViewDeckController the rootViewController of you app and set it's centreController to be your UINavigationController.

    Have your LoginViewController be the topViewController of your UINavigationController at the beginning, thus showing the Login view to start with. If you don't want to see the NavigationBar at Login add this to your LoginViewController:

    -(void)viewWillAppear:(BOOL)animated {
        [super viewWillAppear:animated];
        [self.navigationController setNavigationBarHidden:YES animated:YES];
    }
    
    -(void)viewWillDisappear:(BOOL)animated {
        [super viewWillDisappear:animated];
        [self.navigationController setNavigationBarHidden:NO animated:YES];
    }
    

    To prevent any ViewDeck actions when at Login do this in your ViewDeck's delegate:

    - (BOOL)viewDeckController:(IIViewDeckController*)viewDeckController shouldOpenViewSide:(IIViewDeckSide)viewDeckSide {
        UINavigationController *navController = (UINavigationController*)self.centerController;
    
        if([[navController viewControllers] count] < 2) {
            return NO;
        }
    
        return YES;
    }
    

    Obviously then when the user successfully logs in you just need to push your 'neighbourhoodViewController' onto the stack. And when they log out pop it back off again.