How to push view with navigationbar with ViewDeck

2.2k Views Asked by At

Got a small problem with Viewdeck.

I want to push my navigationview with a navigationbar. I'm now doing (code below) but it's pushing without a navigationbar.

    [self.viewDeckController closeLeftViewBouncing:^(IIViewDeckController *controller)
     {  
    DataViewController *DataController = [[DataViewController
                                           alloc]  initWithNibName:@"DataViewController" bundle:nil];
    DataController.modalPresentationStyle = UIModalPresentationFormSheet;


    DataController.ID = @"hello";

     self.viewDeckController.centerController = DataController;
}];

Also tried:

        UIViewController *viewController = [[DataViewController alloc] init];
        UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:viewController];
        navigationController.modalPresentationStyle = UIModalPresentationFormSheet;


            DataViewController *DataController = [[DataViewController
                                                   alloc]  initWithNibName:@"DataViewController" bundle:nil];
            DataController.modalPresentationStyle = UIModalPresentationFormSheet;


            DataController.ID = @"hello";

             self.viewDeckController.centerController = DataController;
2

There are 2 best solutions below

0
On BEST ANSWER

You're going in the right direction with your first block of code but then you're not using the actual UINavigationController. I'm going to assume that your UIViewController class is DataViewController, so the following should do it:

DataViewController *dataController = [[DataViewController alloc] initWithNibName:@"DataViewController" bundle:nil];
UINavigationController *dataNavigationController = [[UINavigationController alloc] initWithRootViewController:dataController];

Pass it any data you want (I see you're setting the ID property to @"hello" - I'll leave that out). Then, in your closeLeftViewBouncing, just set:

[controller setCenterController:dataNavigationController];
2
On

When you push a view controller to a navigation controller, it always has a navigation bar.But you aren't pushing a view controller with your code.
In my objective-c copybook I've written a small procedure of how doing this:

  1. Create a navigation controller and set it as root view controller of the window, then add the first view controller to the navigation controller;
  2. Add a bar button item to the view controller's navigation item in a way that you can change the view.That navigation item should have an action that pushes the other view controller.