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.
Related
Right now I'm attempting to "extend the navigation bar" by placing a view under the navigation bar with the same color.
The only problem is that I'm using a tableview underneath. And tableviews extend all the way to the top.
I was wondering if there was a way to move the tableview down, so that I could place a view between the navigationbar and the start of the tableview.
Thanks!
You need to constraint the top of the table to the bottom of the view or set top inset to the table
I am trying to implement a horizontal scrolling table view. I was able to accomplish this with the following layout. I have a ScrollView which contains a Container View which points to my NavigationController. Since I made the Container View wider than the ScrollView, the table is able to scroll left to right as expected.
The problem I am having is resizing the Navigation Bar's width as I do not want to have to scroll to view the Navigation Bar's title. I tried explicitly setting the width property of the Navigation Bar in ViewDidAppear however it keeps getting resized to the actual width of the table view. Is there any way I can do this without having to create my own custom view that mimics that Navigation Bar?
I ended up creating my own navigation bar that is placed on top of the actual integrated table view navigation bar.
I have a UITableView as one of the (two) view controllers of a UITabBarController. The tab bar on the UITabBarController is hidden though, but this suits our UX because we wanted the user to be able to switch back and forth between two main screens.
The problem we're seeing, is a margin at the bottom of each of the UITableViewControllers inside the UITabBarController—I assume this is because the tab bar controller expects the tab bar to be visible.
The "Load more" button is the last UITableViewCell in the UITableView.
As you can see in the screenshot below, there's a bottom-margin between the scroll-bar on the right and the actual bottom of the UITableView.
How can I get rid of this margin, and reduce all of the white (grey) space between the last cell and the bottom of the view?
Goto Storyboard -> Attribute inspector
ViewController Section -> Layout -> Uncheck Adjust Scroll View Insets
Hope this help.
Go to the storyboard, and uncheck "Adjust Scroll View Insets" in the ViewController that contains the tableviews.
I've got a gradient background that I want to show through both the navigation bar and the tab bar. I have them set to "translucent black". If I create a ViewController and put a TableView on it, this works perfectly. However, I can't get it to work properly with a TableViewController. The tab bar works fine, but the navigation bar ends up black. If I turn off "Adjust Scroll View Insets", then the navigation bar looks the way I want it, but the top half of the first table view row gets cut off (see examples). The gradient is on the background view. The background colour of the tableview is clear.
Is there any way to get the same effect on a TableViewController? Do I need to somehow make the heading or first row of the tableview be the background that goes under the nav bar?
ViewController with TableView added:
TableViewController with "Adjust Scroll View Insets" ON:
TableViewController with "Adjust Scroll View Insets" OFF:
After doing a test I think you'd need:
Adjusts Scroll View Insets ON
Extend Edges - Under Top Bars ON
No. 1 allow the UITableView to cover the entire screen (including under the navigation bar) and No. 2 adds a space at the top of the UITableView content so that the content is not hidden under the navigation bar.
I ran into a similar issue trying to set a full screen background on a static table view controller with a clear navigation bar. I solved it by using a backgroundView on my tableView instead of setting backgroundColor. For example:
myTableView.backgroundView = UIImageView(image: UIImage(named: "backgroundImg.png"))
I set my navigation bar to clear, but you could style that however you like:
navigationController?.navigationBar.backgroundColor = UIColor.clear
I also had to set Extend Edges - Under Top Bars ON
I have a TableViewController which comes from a TabBarController. Now my problem is that, the TableView becomes scrollable under my NavigationBar on the top which is transparent and I don't want this to happen.
The second thing is that the TableView's last cell goes below the TabBar which makes it impossible to select the last cell.
Can someone suggest me how to resize the TableView, so that I place it perfectly in between the navigationBar on the top and the TabBar on the bottom.
Thanks in Advance.
Select your UIViewController in storyboard and go to Attribute inspector. In Top Bar combo select Opaque Navigation Bar and in Bottom Bar combo selct Opaque Tab bar.