Access navigation bar with container controller

Two questions regarding the UINavigationController and the UINavigatinBar when writing your own container.

1) I created my first container with a storyboard and embedded it in the UINavigationController. The only way I found for my childViewControllers to access the UINavigationBar was doing something like this in the childViewController viewDidLoad view:

UIBarButtonItem *showDetailViewControllerBBI = [[UIBarButtonItem alloc] initWithTitle:@"Show Details" style:UIBarButtonItemStyleBordered target:self action:@selector(switchToCarouselLayout:)];
self.parentViewController.navigationItem.leftBarButtonItem = showDetailViewControllerBBI;

Is this the right way to get a UINavigationBar?

2) I thought I could tickle the UINavigationBar on my first ContainerViewController. What I did was remove the UINavigatinController in my storyboard and put the UINavigatinBar at the top of my ViewController container. When I start the project, the navigation bar does not appear. So, what does the UINavigationBar in IB actually do if I cannot have it in my original container controller without integrating into the UINavigationController? Or is it just for aesthetics and you can only use it with UINavigationControllers? Thank.

+3
source share
1 answer

1) , , - . , self.childViewControllers.lastObject( ).

2) . ? IB, - .

0

Source: https://habr.com/ru/post/1535536/


All Articles