简体   繁体   中英

TabBar is covering the TableViewController's TableView (Swift Solution needed)

I see that this questions has been asked before and answered; however, in objective-c. I tried but could not convert it. Any help is appreciated. This is the code:

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

The first line was easy:

self.edgesForExtendedLayout = UIRectEdge.All

The rest, I need help.

Thanks in advance.

You could do it like this, then you don't need to use the TableView inside of a UIView.

 override func viewDidLoad() {
    super.viewDidLoad()

    let tabBarHeight = self.tabBarController?.tabBar.bounds.height
    self.edgesForExtendedLayout = UIRectEdge.All
    self.tableView.contentInset = UIEdgeInsets(top: 0.0, left: 0.0, bottom: tabBarHeight!, right: 0.0)

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM