Closed ajsharp closed 10 years ago
The view controller hierarchy is done correctly. In which method do you try to access the slideMenuController ?
I've tried to access it in various different methods, after the slide menu controller has been allocated and assigned the content and menu controllers:
UIStoryboard *board = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *menuVC = [board instantiateViewControllerWithIdentifier:@"mainSettingsNav"];
SAStoriesCollectionViewController *collectionVC = [[SAStoriesCollectionViewController alloc] initWithNibName:@"SAStoriesCollectionViewController" bundle:nil];
SANavigationViewController *navVC = [[SANavigationViewController alloc] initWithRootViewController:collectionVC];
NVSlideMenuController *slideVC = [[NVSlideMenuController alloc] initWithMenuViewController:menuVC andContentViewController:navVC];
NSLog(@"slide menu controller=%@", navVC.slideMenuController); // slide menu controller=(null)
It's certainly possible I'm doing something wrong, because I've had this work in another view controller class. But I can't get it to work with a navigation controller or any of it's child view controllers.
The hierarchy is built when the views appear. The menu's view is lazily created when you first open the menu. Try to log the slideMenuController inside viewWillAppear
.
Ah, I see. It's probably worth documenting that in the README.
On another note, it would be nice to be able to get access to the slideMenuController in viewDidLoad, as this is guaranteed to run only once for a view controller.
Great, thanks for the reference point. I'm not sure why this wasn't getting hit in my code. I'll check again and report back.
When I'm initializing an instance of a
NVSlideMenuController
and then assigning the menu and content view controllers, I'm getting inconsistent behavior when trying to use theslideMenuController
within either of the view controllers, where often the property is nil.The
slideMenuController
category method looks for aparentViewController
that is an instance ofNVSlideMenuController
, but the the parent of the menu and content view controllers never gets set to theNVSlideMenuController instance. I think what is needed is just to call
addChildViewController:in the
setContentViewController:and
setMenuViewController:` methods.Would you accept a patch that makes this change?