如何使用tableview制作粘性页脚和页眉? [英] How to make a sticky footer and header with a tableview?

查看:30
本文介绍了如何使用tableview制作粘性页脚和页眉?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在故事板中有一个 UITableView,还有一个页眉和一个页脚,如图所示.

I have a UITableView in the storyboard with also a header and a footer defined as can be seen in the picture.

但是,当我移动单元格时标题消失了(似乎标题是顶部单元格).与页脚相同.它在我浏览完所有单元格后出现.我试图将页眉和页脚移到 Cell 层次结构之外.但这导致不再可见.

However, the header disappears when I move the cell (it seems the header is the top cell). Same thing with the footer. It appears after I have browsed through all cells. I tried to move the header and the footer outside of the Cell hierarchy. But this resulted in being not visible any more.

如何使页眉和页脚具有粘性?

How can I make the header and footer sticky?

推荐答案

不要将节页眉和页脚与表格页眉和页脚混淆.

Don't confuse the section header and footer with the table header and footer.

  • 在未分组的表格中,部分页眉和页脚在您滚动时固定到表格的顶部和底部.

但是,正如您所说,表格页眉和页脚有点像单元格:它们在第一节之前和最后一节之后,并且随着表格滚动.

But the table header and footer, as you rightly say, are sort of like cells: they are before the first section and after the last section, and they scroll with the table.

如果这不是你想要的——也就是说,如果你想一直在表格上方和表格下方显示一些东西——那么你需要将它们作为完全独立的视图放在表格视图的上方和下方:

If that's not what you want — that is, if there is something you want to show above the table and below the table, all the time — then you need to put them above and below the table view as completely separate views:

thing above
table
thing below

当然,如果你这样做,你就不能使用 UITableViewController.你必须有一个普通的视图控制器,表视图作为一个嵌入式视图,表视图控制器作为一个视图控制器.

Of course, if you do that, you can't use a UITableViewController. You'll have to have a normal view controller, with the table view as an embedded view and the table view controller as a child view controller.

这篇关于如何使用tableview制作粘性页脚和页眉?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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