4
votes

I have a grouped UITableView. I've implemented tableView(:titleForHeaderInSection:) and tableView(:titleForFooterInSection:). As I scroll a long table, I can see that the section headers and footers contain the expected data. When I get to the bottom of the table and I drag up to see the footer of the last section, it has the correct data, but when I release my finger, the footer scrolls back down past the bottom of the screen and out of view. The last cell of the last section is what appears at the bottom of the screen rather than the footer of the last section.

How to fix it? There's the last section and its footer. My finger is still on the screen

When I release my finger, the final footer slides off the bottom of the screen.

2

2 Answers

2
votes

You can fix scrolling content issue by considering one of the following methods.

Method 1: Natural way to fix your problem by setting up your tableView frame and its bottom constraint properly from your storyboard.

Updated:

walkthrough of changes

Method 2: You can validate your tableView frame in viewDidLayoutSubviews or viewWillLayoutSubviews

 override func viewDidLayoutSubviews() {
     tableView.frame = CGRect(x: 0, y: 0, width: tableView.frame.width, height: tableView.frame.height - (tabBarController?.tabBar.frame.size.height)!)
 }

Method 3: Setting up your tableView frame by adjusting scroll view insets.

override func viewDidLayoutSubviews() {
    tableView.contentInset = UIEdgeInsets(top: 0, left: 0, bottom: (tabBarController?.tabBar.frame.size.height)!, right: 0)
}
1
votes

I think it's blocked by the tabbar.
If using storyborad, reset the constraint of your tableView.
If not, you need to set the frame of your tableView correctly.