Extra space at the bottom of the view controller? - ios

I am using a storyboard with a custom tab bar controller.
When view controllers are added through the storyboard references, with a container(embedded) view, it creates an extra space at the bottom of the view controller, ie just above the tab bar.
The dimension of the space seems to be the same as that of the tab bar height. Is there any solution for this issue?

Check the following in storyboard :
Extend Edges
1. Under Opaque Bars
2. Under Bottom Bars

Related

Remove the gray bar at the bottom of view controller - iOS

The image shows the View controller and the bar I want to remove. And also the structure of the view controller:
Someone told me how to remove the grey bar present at the bottom of the view controller as shown in the image. Unable to select and delete the bar. When I try to add the tab bar in that place, it goes behind the grey bar and becomes invisible.
What do your simulated metrics look like?
Can you get rid of the bar by changing the bottom setting?
Couple of things - if you are using autolayout, just make a constraint to the bottom of the container, with 0 value for the constraint. That will take it to the bottom. Second thing I would add is a zero size table view footer to the tableview.
This is a toolbar that comes with the UINavigationController that the View Controller is embedded in. Assuming you have a Navigation Controller on the storyboard connected to the view controller, select it and in the attributes inspector deselect "Shows Toolbar". If you want to do this in code you can get and set isToolbarHidden on a UINavigationController instance.

Adding a view above UINavigationBar

I'm trying to add a custom view above the navigation bar as displayed on the following image .
What I've tried so far is to add the view as a subview of the navigation bar - Did not work
Add the custom view first on Interface builder and then add a navigation bar manually - This seems to mess up with my navigation as the default navigation controller has it's own navigation bar.
Is this a bad approach on its own ?
If this is a view that will appear above all navigation bars in the app, why not use a Container View?
Make the Container View fill the screen, but give it a 20 point top margin to fit your custom green view. Then when you add your main view controller (wrapped in a navigation view controller) to the Container View, it will show your green view above it.
If you don't want your margin in a particular screen, do the following:
Add a constraint to the top margin and add an outlet to it so you can modify the constraint's constant in code.
Then, in any screens where you don't need the margin, access the parent view controller view and set the constraint's constant to zero.
let myParentViewController = self.parentViewController as? MyParentViewController
myParentViewController.myTopMarginLayoutConstraint.constant = 0
Don't forget to reset it to 20 (or whatever) when you go to a screen where you need the top margin again.

Hide UINavigationBarController in first view controller and AutoLayout

I have a design for an app with 3 screens where the
A) initial screen shall not show top navigation bar
B) second screen shall show top navigation bar (with a nav back button to A)
C) third screen shall not show top navigation bar (but a normal button back to B)
I chose to embed the view controllers in a navigation bar.
But doing so the AutoLayout constraints on the first view controller poops out plenty of warnings - because the embedded UIViews are pinned to the top bar - which is really annoying.
Of course if I "hide" the navigation bar in the storyboard designer, I am no longer able to add the required buttons for by B screen.
An alternate option COULD be to implement the navigational properties of my app all manually, but I really want to avoid doing this.
What is the preferred (best practice) solution to this?
Its Too simple...
you just set hidden attribute of navigation controller in viewWillAppear ex:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
self.navigationController.navigationBarHidden=YES/NO; //as per your requirement
}
As noted in #SonuPatel answer, you can set the navigation bar to hidden relatively easily. For layout:
In controllers A and C, make your top layout offsets relative to the view and not the top layout guide. This will make them layout under the navigation bar when it is not visible. Hidden items usually still contribute to layout, so the topLayout guide is unaffected by it being hidden.
In controller B, make your top layout relative to the top layout guide to keep it below the navigation bar.
For a UITableViewController, you can get this for free by selecting Extend Edges Under Top Bars in the attribute inspector.

UITableViewController Inside UINavigationController and UITabBarController Bottom Inset Off

I have a UITableView inside a UINavigationController that's inside a UITabBarController. There is a view on the bottom (I'll call it bottomView) between the table view and the tab bar that needs to stay at the bottom as the table view scrolls, so I can't put it as a footer in the table view.
The issue is that when i scroll to the bottom of the table view, there is an empty space the same height as the tab bar between the lowest content (and the scroll bar) and the top of bottomView.
I think this is because the table view is trying to automatically compensate for the tab view at the bottom, but I can't position it all the way at the bottom because of bottomView.
here's my IB layout:
and the display (last tableViewCell highlighted):
If I understand your question correct you need to set a contentInset to your tableView like this:
[self.tableView setContentInset:UIEdgeInsetsMake(0,0,44,0)];
Edit:
Ok I think I got it. Set:
self.automaticallyAdjustsScrollViewInsets=NO;
I've seen this same nav controller->tab bar->tableview situation frustratingly cause the tableview to partially overlap with the navigation bar, instead of not reaching the tab bar. To anyone having this issue when using a UITableView: ensure your navigation bar is not translucent. If you want to use this setup with a translucent navigation bar, select the UITabBarController in the Interface Builder and uncheck the "extend edges under top bars" option in the attributes inspector.

Navigation bar View Controller is twice the size as others

I have a multiple View Controllers embedded in Navigation Controller and one of my navigation bars is twice the size(extends down twice as much) as every other one. I want all of these bars to be the same size, but can't find anyway to change the size in Inspector. There are no bar buttons on this Navigation Bar. Any ideas for a quick fix w/o having to rebuild this VC?
Thanks
Default UINavigationBar have a height of 44 points and it can't be changed. I think you have a constraint issue: select your wrong sized UINavigationBar and on the top right corner, in the "utilities", select "size inspector". Then, have a look at the severals constraints, edit and/or delete some.

Resources