Question

I'm trying to write a slide out menu that uses a main viewcontroller(VC) and three subviews. I want the subviews to be able to be UINavigationControllers if I want...but I'm having trouble adding them as children of the main VC.

The main view is the delegate of the center view.

What seems to be happening is that the nav bar is being given to the main vc and not retained by the child (if that makes any sense). See Image:

enter image description here

I've recently downloaded another library that yields the desired effect (CHSliderMenu) and it works just fine in iOS6/7, but I'm unable to distinguish the difference between what the author is doing and what I'm doing. I know I'm close, which is what's making this so hard to figure out :(

Here is the code in my MainViewController that attempts to add the child nav controller:

self.view.frame = self.view.bounds;

_centerViewController = [[D2CenterViewController alloc] init];
_centerViewController.view.backgroundColor = [UIColor whiteColor];
_centerViewController.view.tag = CENTER_TAG;
_centerViewController.delegate = self;

UINavigationController *centerNavController = [[UINavigationController alloc] initWithRootViewController:_centerViewController];

[self addChildViewController:centerNavController];
[self.view addSubview:centerNavController.view];

Can you see where I may have gone wrong? Is more code needed to diagnose?

Was it helpful?

Solution

I implemented one which is built on top of a UINavigationController. In order to display the menu behind the navigationController you need to add the menu to the main window of the application instead of adding it as a subview of the navigation controller.

It also seems like you are moving the viewController inside the navigation controller, instead you need to move that view of the navigation controller, that way all content including the navigation bar can be moved.

https://github.com/aryaxt/iOS-Slide-Menu

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top