Place content under iOS UITabBar - ios

I'm trying to place my content under UITabBar. I created a Storyboard with controller in it and attached UIView to the bottom of content view of that controller(with constraints). After that, i created another Storyboard with UITabBarController and linked one of the tabs to the first Storyboard by storyboard reference. And the problem is that my UIView appearing always above the UITabBar while i want it to be under tab bar. Is there any way to achieve my goal?
Storyboard with UITabBarController
Storyboard with my view attached to the bottom of the content view

For using tabbarcontroller you should follow below scenario :
Drag tabbarcontroller to canvas (interfacebuilder), it will comes with two default view controllers. That means initially you have two tabs.
If you want more tab the drag another view controller to interface builder and then from tabbarviewcontroller ctrl + drag to that new View controller and from popup select relationship segue (viewController).
By this way you will able to new tab in tabbarcontroller and view in you tabs will not cover tabbar.

Related

Is it possible to use a single UIView across multiple UIViewControllers?

I have 6 UIViewControllers in my app at the moment, and while they are all different, they should all share the same custom toolbar at the top, as well as a drawer which is opened/closed by a button on said toolbar. The "toolbar" and "drawer" are both UIViews with some stuff inside. Is it possible to use the same UIView objects for all 6 of my UIViewControllers? Or do I have to copy the constraints, segues, controller code, etc for the toolbar and drawer for each UIViewController that I have in my app?
Take a look at containerView.
You can add containerViews in each of your ViewControllers and embed your UIView.
What you could do in this situation is make a view controller that embeds a child view controller. On this view controller, you would set up your toolbar and drawer, then you would have a Container View that can embed a navigation controller which would manage all your other view controllers. On a storyboard, you can right-click and drag from a Container View to another controller to embed it.

Why does embedding a View Controller in a Navigation Controller, then in a Tab Bar Controller attach the nav bar to the Tab Bar Controller?

Back when I first created the foundational layout for the app I'm currently working on in Storyboard, I did it in two steps:
Selected my View Controller and used Editor->Embed In->Navigation Controller.
Selected my View Controller again and used Editor->Embed In->Tab Bar Controller.
This was the resulting layout:
Question 1: Why do these steps create such an odd layout?
In this weird layout that seems to imply that the Navigation Controller is attached to the Tab Bar Controller as its parent, the only way I can get navigation items to display in the app (in the view controlled by the View Controller on the right) is by placing them in the nav bar of the Tab Bar Controller scene.
However, this creates various issues, including not being able to create an IBOutlet in my View Controller file for a custom view I drag into the title view slot in the Tab Bar Controller scene. Meanwhile, dragging anything into the navigation bar in the View Controller scene just makes it not appear in the app when it runs.
Question 2: How can I fix this layout so that I can control-drag from navigation items into my View Controller file? Or is everything actually correct, and I'm just trying to force something I shouldn't? (My intention here is to be able to set the custom title view's text in my View Controller code.)
Its obvious, if you want to embed MyViewController to NavigationController then you need to change your second step and need to embed NavigationController to Tab Bar Controller.
Selected MyViewController and used Editor->Embed In->Navigation Controller.
Selected NavigationController Embed with MyViewController and used Editor->Embed In->Tab Bar Controller.
It should look like this.
Note: You need to embed MyViewController to navigationController only if you want to perform push operation on this TabBarItem means with MyViewController other wise simply embed MyViewController to TabBarController no need to embed it with NavigationController.

Using storyboard references with UINavigationController

I have the following hierarchy in my app: UITabBarController to many UINavigationControllers. Each navigation controller has a UIViewController.
I’ve split this up so that each UITabBarController’s child view controller is linked via a storyboard reference. In each of these references there’s a UINavigationController as the initial view controller.
Again some of these other storyboard references are split up too, where one of the UINavigationController’s child view controllers also uses a storyboard reference.
These UINavigationController’s child view controllers in the new storyboards do not carry across the UINavigationController style. Unlike the UITabBarController which does take across the UITabBarItem and shows them in the UINavigationController.
Is there anything I can do to see the navigation item of these UINavigationControllers so I can add bar button items in IB?
It's straight forward really; just go to Editor > Embed In > Navigation Controller and embed your view controller in a UINavigationController. You can then select the UIBarButton items under the Object Library in xCode, drag and drop them to the navigation bar on your View Controller and voila!
You can then delete the UINavigationController when done with adding the UIBarButton items to your VC; those bar button items will still be referenced and shown in the final product when you run it.
In Storyboard go to the Attributes Inspector for the Controller you wish to add the navigation bar and click on top bar drop down instead of it saying 'inferred' click on 'Translucent Navigation Bar'

Add UIBarButtonItem in Interface Builder to navigated UIViewController?

I have a UINavigationController in Interface Builder in a storyboard. I've added two UIBarButtonItems to the first UIViewController. They display just fine. How can I add them to the second UIViewController which is navigatated to? On that view controller, I only see the Back button.
When I try dragging a UIBarButtonItem to the top of the second view controller, the button ends up at the bottom of the scene for some reason. It is not displayed when running the app.
Edit: I should have mentioned that I know how to do this in code, but not in Interface Builder.
To add further informations about my comments concerning navigation item :
Here is a simple project with a UIViewController embedded in a UINavigationController. A second UIViewControllercan be pushed via the Next button.
If you select the next button, you can see in the hierarchy that this button is embedded within the group Right Bar Buttons Items, which is embedded within the First object. In fact, First is a UINavigationItem automatically added to your view controller when it was embedded in the navigation controller.
But the second view controller (the pushed one) doesn't have this navigation item since it isn't directly embedded within a navigation controller. Simply drag and drop it from the Object Library to your view controller.
#Slack, As i said earlier just drag and drop 2 "bar button item" in your navigation bar.

How to resize UINavigationController in a storyboard editor

When I want resize an UIViewController in a storyboard editor window I do:
I put size to "freeForm" in the UIViewController attributes inspector
I select the view and resize her with the size inspector
after that, the uiViewController is resized in storyboard window.
Next, I select the view controller, click on: edit > embeded in> Navigation Controller and the problem is that navigation controller is in full size and not the same size that UIViewController. I don't find how resize this navigation controller.
There's a trick to get around this limitation. Add a view controller to your storyboard and then add a Container View as a subview to it's view. Size that container view to the size you want the navigation controller (and it's children) and then control drag from the container controller to your navigation controller. You can then instantiate the navigation controller by identifier and the container view controller will be ignored.
You don't resize a NavigationController - it is not a ViewController. It controls the navigation of ViewControllers. You specify an initial ViewController (the one you embedded into it will be the initial viewController by default). You then create segues into other ViewControllers.

Resources