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

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.

Related

Can I use storyboard to embed UINavigationController's view inside a UIViewController?

I want to keep the top and bottom sections of my view stationary and I only want to add a navigation controller at the center of the screen.
This has been perfectly doable for a lot of years and now as everyone is so enchanted by the Storyboards, I wanted to do the same through the storyboard and it seems like it is impossible.
Is it possible anyways?
you can use Container View in the storyboard.
Container View defines a region within a view controller's view
subgraph that can include a child view controller. Create an embed
segue from the container view to the child view controller in the
storyboard.

Place content under iOS UITabBar

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.

Using iOS 6 autolayout, what would be the proper way to display somthing above an UINavigationController?

In my app, i have a main view controller which sometimes brings a modal view on top of it. This modal view is a UINavigationController with a navigation bar. I want to display an image above the navigation bar, and have the navigation bar appear below the image.
I do not want to subclass anything and the app uses autolayout, i do not want a bunch of delegate callbacks and frame calculations. The view inside the navigation controller (the actual modal content) must still respond to different screen sizes correctly, such as rotation, call status bar etc. Also, no IB solutions please, these views are all managed in code.
How do i accomplish this?
I would turn off AutoLayout and place the image at the top
I don't think you can do it with your modal view being a navigation controller. I would do it by making that modal controller a UIViewController that you set up as a custom container controller. You can add an image view to the top of this controller's view and add the view of a child view controller (which would be a navigation controller) to the bottom. This would be a lot easier to do in a storyboard using container views, but it certainly can be done in code.

How to organize Controllers and Views (iOS)

I want my UITabBarController to be with frame (0;100;320;380).
In addition to UITabBarController I want to have a view with frame (0;0;320;100).
This view is supposed to be independent from TabBarController and always visible. When different Tabs are opened top view should remain visible, like UINavigationBar.
Is there any way to do it?
Create a UIViewController subclass, in the xib add two views, one upperview and another lowerview with the sizes you want
In the view did load of this view controller, create a UITabBarController, and add to it the view controllers you wish
then do
[lowerview addSubView:tabBarController.view];
[upperview addSubView:yourUpperView];

Adding a toolbar to a navigation controller

I am completely new to ios development and I am only interested in developing for ios5.
I have an app with some scenes, they are mostly tableviews. I also use a navigation controller
I however need to add some status text and buttons that are always visible in all scenes and thought that a toolbar added to the navigation controller should do the trick.
so i thought that i should only have to drag out a toolbar in storyboard to the navigation controller, but it does not stick there. I can add it to the bar underneath with first responder and navigation controller but that does not help me (small icons).
I can also not add it to my table view (but if i drag out a plain view I can add it there)
do I have to make my own custom navigation class that the navigate view uses and then programatically add my toolbar?
Had the same question recently. Check Attributes Inspector in your ViewController's properties in storyboard. There you can define a Bottom Bar.
Well, inside the UINavigationController, you should have something... A UIViewController for instance. You can easily add a UIToolBar by dragging the object inside the UIView of the UIViewController. What might being happening is that as the root view you have the UITableView, in that case I think you can't do that. But to better understand, just take a small print screen of your StoryBoard.
If you zoom up to 100% on the storyboard it should drag.

Resources