Tableview last row is cut off under tabbarcontroller

南笙酒味 提交于 2019-12-06 20:00:30

Try this inside viewDidLoad method

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.edgesForExtendedLayout = UIRectEdgeAll;
    self.tableView.contentInset = UIEdgeInsetsMake(0.0f, 0.0f, CGRectGetHeight(self.tabBarController.tabBar.frame), 0.0f); 
}

A little late to the party but the swift solution to this would be to just add the line:

self.edgesForExtendedLayout = .None

to your ViewController's ViewDidLoad

Swift 3

I had this problem and was searching for answers for hours. Going into storyboard and unchecking "Under Bottom Bars" didn't work. I came across this answer but kept getting a nil when trying to access the height of the tabBar like Sanjay did. I hardcoded the tabBar height instead and it was all gravy.

In viewDidLoad add the following:

override func viewDidLoad() {
    super.viewDidLoad()

    let tabBarHeight = CGFloat(49)
    edgesForExtendedLayout = UIRectEdge.all
    tableView.contentInset = UIEdgeInsets(top: 0.0, left: 0.0, bottom: tabBarHeight, right: 0.0)
}

It's caused by the TabBar being translucent by default in IB, if you don't need this effect you can change it with code:

override func viewDidLoad() {
  super.viewDidLoad()

  tabBarController?.tabBar.isTranslucent = false
}

Or in IB by selecting your tabBar and uncheck the Translucent box.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!