UITableView - The footer of the last section scrolls to the bottom of the screen. How to prevent?

I have a grouped UITableView. I have implemented tableView (: titleForHeaderInSection :) and tableView (: titleForFooterInSection :) . When I go through the long table, I see that the section headers and footers contain the expected data. When I get to the bottom of the table and I drag to see the footer of the last section, it has the correct data, but when I release my finger, the footer scrolls back down to the bottom of the screen and goes out of view.The last cell of the last section is this is what appears at the bottom of the screen, not the footer of the last section.

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

When I unlock my finger, the last footer slides to the bottom of the screen.

+3


source to share


2 answers


You can fix the content scrolling issue by looking at one of the following method

.

Method 1: The natural way to fix your problem by setting up tableView frame

and bottom constraint

s StoryBoard

.

Updated:

enter image description here



Method 2 . You can confirm your tableView frame

in viewDidLayoutSubviews

orviewWillLayoutSubviews

 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 : customize the tableView calendar by changing the scroll view insets

.

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

      

+1


source


I think it is tab-locked.
If you are using storyborad, reset the constraint of your tableView.
If not, you need to set up the frame of the tableView correctly.



+1


source







All Articles