11

I'm developing an application based on the Tab Bar application preset. In one of the tabs I have a table view showing a lot of data, but half the last cell in the table view is covered by the tab bar when I've scrolled to the bottom.

Anyone has a solution to this?

Accatyyc
  • 5,798
  • 4
  • 36
  • 51

12 Answers12

17

Adding a footer space worked for me:

//this prevent the tabbar to cover the tableview space
UIView *footer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 1, 90)];
footer.backgroundColor = [UIColor clearColor];
myTableView.tableFooterView = footer;
  • After a whole day of trying different answers, this is the only one that worked. I don't even care if it's a hack at this point – W.K.S Jul 16 '16 at 14:10
11

This did the trick here (within Interface Builder):

TableView above TabBar

backslash-f
  • 7,923
  • 7
  • 52
  • 80
  • 1
    If you have this problem in iOS7 building your view with storyboard, this is the right solution for you. Thanks Conaaando! – Nacho L. Aug 08 '14 at 15:08
4

There are a couple of solutions for this.

1.) Assuming that you are using translucent tool bars, you have to make the tool bars opaque.

2.) If you are using StoryBoard and you are putting a TableView inside your ViewController, assuming it's a ViewController and not a TableViewController.

3.) You can manually add padding/spacing.

if ([self respondsToSelector:@selector(edgesForExtendedLayout)])
{
    self.edgesForExtendedLayout = UIRectEdgeNone;
    self.extendedLayoutIncludesOpaqueBars = YES;
    self.automaticallyAdjustsScrollViewInsets = NO;
}

or

UIEdgeInsets insets = UIEdgeInsetsMake (0,sizeOfTableView - sizeOfTabBar, 0, 0);
self.tableView.contentInset = inset;
self.tableView.scrollIndicatorInsets = inset;

Hope this helps & Happy coding!

Chris
  • 1,004
  • 2
  • 11
  • 25
3

Look at the size of the tab bar, and adjust the size of your table view accordingly. Read the docs on the frame property, IB lets you set the size of things if you're using IB for this purpose, etc.

jer
  • 20,094
  • 5
  • 45
  • 69
2

Swift 3:

This is what worked perfectly for me. This code not only stop the last cell showing behind the tab bar, but also pushes up the scroll indicator. Put the code in your viewDidLoad():

if let bottomInset = navigationController?.tabBarController?.tabBar.frame.size.height {
    tableView.contentInset.bottom = bottomInset
    tableView.scrollIndicatorInsets.bottom = bottomInset
}

or you could do this:

override func viewDidLayoutSubviews() {
    super.viewDidLayoutSubviews()
    tableView.contentInset.bottom = view.safeAreaInsets.bottom
    tableView.scrollIndicatorInsets.bottom = view.safeAreaInsets.bottom
}
Kasra Babaei
  • 300
  • 1
  • 3
  • 12
2

REAL ANSWER:

I had this problem, and ended up here ... So even if this is old, here is how I solved this issue:

I had a UITabBar controller with one tab being a UIViewController, and it had a single added line:

[self.view addSubview:navController.view];

This is wrong .. Even if the code worked, the concept is wrong (at least in my case), the navController should be directly linked in the UITabBar as one of the tabs...

So, what's the real answer?

You must have implemented the navigation controller incorrectly. As proof is that I had this issue, as I explained, and also This Guy...

Mazyod
  • 22,319
  • 10
  • 92
  • 157
1

I just solved this problem by adding constant number... hard coding... How about finding threshold value fit to you?

LKM
  • 2,410
  • 9
  • 28
  • 53
1

I've found the only solution to this is to add a padded footer for the tableview:

http://www.iphonedevsdk.com/forum/iphone-sdk-development/18180-resizing-uitableview-programatically.html

Accatyyc
  • 5,798
  • 4
  • 36
  • 51
0

Select the view where you have your tableview, open attribute inspector, in Simulated Metrics section, select Tab Bar for Bottom Bar item.

Then XCode would update your view, reserving space for TabBar. So your tableview would not be covered.

Mihai Iorga
  • 39,330
  • 16
  • 106
  • 107
Gon
  • 1,135
  • 12
  • 22
0

For me it was just that the table view in UIViewController didn't have any constraints, once I pinned in to the edges of the view it fixed itself.

Pawel Jurczyk
  • 165
  • 2
  • 10
0

SWIFT

I had been having this problem where when I embed a UITableViewController into a UITabBarController, the last cell (or the bottom or a large cell) would remain under the TabBar when fully scrolled down. After a day of trying various codes and work arounds which didn't work, I simply re-embeded my UITableViewController into a Navigation Controller which was them embedded into a TabBar Controller. The spacing is fixed and the table view clears the tabBar now.

A.J. Hernandez
  • 969
  • 11
  • 13
-2

I think you have a custom Tabbar, you need reset the height of Tabbar equal to the height of the background image of this Tabbar.

UITabBar * tabbar = self.tabBar ; 
[tabbar setBackgroundImage:[UIImage imageNamed:@"image.png"]] ; 
[tabbar setFrame:CGRectMake(0, 480 - imageHeight, 320, imageHeight)];