9

In my storyboard, I have a View controller (embedded in a navigation controller). Inside the view controller I have a tab bar controller, and inside a tab a table view controller. My problem is that the last row of the table view goes "under" the tab bar of the tab bar controller. This didn't happen if i build my app for iOS 6.

How can I solve this? Thank you!

forrest
  • 10,570
  • 25
  • 70
  • 132
ace_ventura
  • 468
  • 1
  • 4
  • 14

5 Answers5

19

Try setting your tabbar translucent property.

self.navigationController.navigationBar.translucent= NO; // Set transparency to no and

self.tabBar.translucent= NO; //Set this property so that the tab bar will not be transparent

Marlon Bernardes
  • 13,265
  • 7
  • 37
  • 44
Priyatham51
  • 1,864
  • 1
  • 16
  • 24
  • It was already set from Interface builder but i dont know why it didn't work. With your solution it's ok now, thank you! – ace_ventura Sep 26 '13 at 15:49
  • I thought we need to set it in run time. I didn't observe the option in Xcode. I will go and search for it now. :) – Priyatham51 Sep 26 '13 at 15:52
  • wait, i get something very strange here. If my build for my device, it's ok. if i build for the simulator, i get this error for the self.tabBar.translucent = NO; property translucent not found! how can be possible?? – ace_ventura Sep 26 '13 at 15:58
  • 2
    Make sure you are running in iOS7 simulator. – Priyatham51 Sep 26 '13 at 16:13
2

This, as said, will work perfectly. I've just tested it.

self.tabBar.translucent = NO;
Steph Sharp
  • 11,462
  • 5
  • 44
  • 81
John Maval
  • 27
  • 1
2

The accepted and upvoted answers don't work for my setup:

UITabBarController -> UINavigationController -> UIViewController -> UITableView

My app's root view controller is a UITabBarController. Every tab is a UINavigationController, and in one tab, the navigation controller's root is a UIViewController with a table view as the main view.

So here's what worked for me: When alloc-initing the UITableView, I compute for the height and set it in the table view's frame. The general formula is screen height - (status bar height + nav bar height + tab bar height).

Matthew Quiros
  • 13,385
  • 12
  • 87
  • 132
1

I think it has to do with automaticallyAdjustsScrollViewInsets not being applied (or applied correctly) due to the nested structure of your view controller hierarchy.

Try and copy your table into a new UIViewController and make sure the checkmark in the UIViewController's identity inspector called "Adjust Scroll View Insets" is turned on.

Steph Sharp
  • 11,462
  • 5
  • 44
  • 81
Wirsing
  • 6,713
  • 3
  • 15
  • 13
0

I had the same problem, and the up-voted answers did not solve it. See my answer to a similar question, Tab Bar covers TableView cells in iOS7.

I solved the issue by manually setting the table view's frame in the table view controller's viewWillAppear: method (as suggested by Matt Quiros) to the height of the screen - (status bar height + nav bar height + tab bar height).

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];

    // Adjust height of tableview (does not resize correctly in iOS 7)
    CGRect tableViewFrame = self.tableView.frame;
    tableViewFrame.size.height = [self heightForTableView];
    self.tableView.frame = tableViewFrame;
}

- (CGFloat)heightForTableView
{
    return CGRectGetHeight([[UIScreen mainScreen] bounds]) -
           (CGRectGetHeight([[UIApplication sharedApplication] statusBarFrame]) +
            CGRectGetHeight(self.navigationController.navigationBar.frame) +
            CGRectGetHeight(self.tabBarController.tabBar.frame));
}

If anyone finds a better solution to this problem, please share!

Community
  • 1
  • 1
Steph Sharp
  • 11,462
  • 5
  • 44
  • 81