UITableView-最后一部分的页脚滚动到屏幕底部.怎么预防? [英] UITableView - footer of last section scrolls off the bottom of the screen. How to prevent?

查看:131
本文介绍了UITableView-最后一部分的页脚滚动到屏幕底部.怎么预防?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个分组的UITableView.我已经实现了 tableView(:titleForHeaderInSection:) tableView(:titleForFooterInSection:).滚动长表时,可以看到节的页眉和页脚包含预期的数据.当我到达表格的底部并向上拖动以查看最后一节的页脚时,它具有正确的数据,但是当我松开手指时,页脚向下滚动回到屏幕底部并超出视线范围.最后一部分的最后一个单元格显示在屏幕底部,而不是最后一部分的页脚.

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.

如何解决? 最后一节及其页脚.我的手指仍在屏幕上

当我松开手指时,最后的页脚滑出屏幕底部.

推荐答案

您可以通过考虑以下方法之一来解决滚动内容问题.

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

方法1::通过在情节提要中正确设置tableView框架及其底部约束来解决问题的自然方法.

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

已更新:

方法2 :您可以在viewDidLayoutSubviewsviewWillLayoutSubviews

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

方法3 :通过调整滚动视图insets设置tableView框架.

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

这篇关于UITableView-最后一部分的页脚滚动到屏幕底部.怎么预防?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆