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

不羁岁月 提交于 2019-12-23 12:08:45

问题


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.


回答1:


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:

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



回答2:


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.



来源:https://stackoverflow.com/questions/43105065/uitableview-footer-of-last-section-scrolls-off-the-bottom-of-the-screen-how-t

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