Tableview last row is cut off under tabbarcontroller

徘徊边缘 提交于 2019-12-08 05:58:01

问题


I'm having a Tabbarcontroller and in the first tabview I'm having a tableviewcontroller. Now the last row is half visible the rest is underneath the tabbarcontroller.

I've unchecked extend edges in the interface builder of my tabbar controller but nothing changes.

I also tried this in my tableview controller:

self.edgesForExtendedLayout = UIRectEdgeNone;

But still the last row is half underneath the tabbar.

Someone an idea how I can solve this?


回答1:


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); 
}



回答2:


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




回答3:


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)
}



回答4:


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.



来源:https://stackoverflow.com/questions/29469267/tableview-last-row-is-cut-off-under-tabbarcontroller

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