Prevent footer overlapping tableViewCell in UITableView - Swift

前端 未结 7 1240
萌比男神i
萌比男神i 2020-12-18 06:31

I have this table view which works how i want it to however i have a problem where the footer overlap the cells in the table view as seen in

How can i prevent this?

相关标签:
7条回答
  • 2020-12-18 07:05

    Try to override this method

    override func tableView(tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return 44.0
    }
    
    0 讨论(0)
  • 2020-12-18 07:07

    Just add some padding to the bottom of the content so that it doesn't overlap with the footer:

    self.tableView.contentInset = UIEdgeInsetsMake(0, 0, FOOTER_HEIGHT, 0)
    
    0 讨论(0)
  • 2020-12-18 07:13

    I know this is an old thread, so this is more so for others that encountered this (like myself).

    The floating section footer is default behavior from my understanding. There are a couple of options that I can think of:

    Provide your footer view with a background color (footerView.backgroundColor = UIColor.white) thus cleaning up the overlap.

    or

    Replace the section footer with a custom "Total Calories" cell that you add to the table after the last cell in that section, effectively acting like a footer cell.

    0 讨论(0)
  • 2020-12-18 07:15

    Sorry for the delay. If you have modified the standard contentInsetAdjustmentBehavior of the tableView, you must adjust the tableView contentInset property to take into account the total height of the views at the bottom of the UITableView, like the tab bar. If contentInsetAdjustmentBehavior is set to "automatic" (or you didn't change the default value), then set the clipsToBounds property of your footer view to true so that its child views cannot be painted outside the footer view layer's frame. That should solve your issue.

    0 讨论(0)
  • 2020-12-18 07:22

    You can do that, Just make Style Grouped as shown below:

    0 讨论(0)
  • 2020-12-18 07:23

    Of course it overlaps. This is how footers and header work in UITableViews. You can set the footerView.backgroundColor to UIColor.gray, for example, to make it look better.

    0 讨论(0)
提交回复
热议问题