如何使用tableview制作粘性页脚和页眉?

编程入门 行业动态 更新时间:2024-10-07 17:31:18
本文介绍了如何使用tableview制作粘性页脚和页眉?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我在故事板中有一个 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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-29 01:15:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1182568.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:页眉   粘性   如何使用   tableview

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!