accessing navigation bar with container view controller


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.


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.


  • Game Center In SpriteKit Not Dismissing Leader Board
  • NSTask waitUntilExit hanging app on jailbroken iOS
  • Setting custom UITabBarItem programmatically?
  • Programmatically add a back button to a UINavigationBar?
  • Changing Machine Type on Google Cloud
  • SvcUtil.exe vs Add Reference
  • user , comment association not working, comment.user.email returns No method error?
  • Alternative to XInclude
  • Connect to OLEDB data source from Java?
  • How to notify a specific thread in Java
  • Cannot run the macro
  • Eclipse terminate shotcut
  • Push Changes to Git not Functioning
  • getting domain details and portrait_id and landscape_id for openX
  • What is wrong in my MVC implementation?
  • SSRS 2008 - Sorting within a group
  • How do I add a UIAlertController in app delegate (obj-c)
  • “A GKScore must specify a leaderboard.”
  • Where these are stored?
  • Getting the scrolling offset when storing coordinates
  • Bootstrap (v3.3.4) glyphicons not displayed in IE when refresh page (F5)
  • Question about instantiating object
  • Implementing “partial void” in VB
  • SAVE attribute needed for Fortran variables when only the C_LOC address is returned to a C program?
  • Sending HTML Form Data to Spring REST Web Service
  • Sonar maven jacoco code coverage for Multimodule project
  • NSScanner Loop Question
  • Custom validator control occupying space even though display set to dynamic
  • How do I alternate colors in Flat List (React Native)
  • Listbox within Listbox and scrolling trouble in Windows Phone 7 Silverlight
  • Master page gives error
  • Shallow update not allowed (git > 1.9)
  • Eraser for UIBezierPath
  • what is the difference between the asp.net mvc application and asp.net web application
  • jquery mobile loadPage not working
  • Unanticipated behavior
  • Compare two NSDates in iPhone
  • Matrix multiplication with MKL
  • How to include full .NET prerequisite for Wix Burn installer
  • Qt: Run a script BEFORE make