Search code examples
objective-ciosxcodeviewdeck

How to push view with navigationbar with ViewDeck


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;

Solution

  • 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];