Two questions regarding UINavigationController and UINavigatinBar when writing your own container.
1) I created my initial container with a storyboard and embedded it in a UINavigationController. The only way I found for my childViewControllers to access the UINavigationBar was doing something like this in the childViewController's viewDidLoad:
UIBarButtonItem *showDetailViewControllerBBI = [[UIBarButtonItem alloc] initWithTitle:@"Show Details" style:UIBarButtonItemStyleBordered target:self action:@selector(switchToCarouselLayout:)]; self.parentViewController.navigationItem.leftBarButtonItem = showDetailViewControllerBBI;
Is this the proper way to get the UINavigationBar?
2) I thought I could slap in a UINavigationBar onto my initial ContainerViewController. What I did was delete the UINavigatinController in my storyboard and put a UINavigatinBar at the top of my containerViewController. When I run the project, no navigation bar shows. So what does the UINavigationBar in IB actually do if I can't have it in my initial container view controller, without embedding in the UINavigationController? Or is it just for aesthetics and you can only use it with UINavigationControllers? Thanks.Answer1:
1) Yes, I think that is an OK way to reference something from a child view controller. Another way, would be to define that bar button item in the container controller itself and then set the target to self.childViewControllers.lastObject (assuming there's only one).
2) This should work. Did you drag in a navigation bar, or just change the simulated metrics of the top bar to navigation bar? The latter is only for visual layout in IB, as far as I can tell -- it doesn't actually add one.