简体   繁体   English

iOS:tableView的静态sectionHeaderView

[英]iOS: static sectionHeaderView for tableView

Background: I have implemented a standard tableView that has 4 sections. 背景:我实现了一个标准的tableView,其中包含4个部分。 Each of the section contains a custom view for the header. 每个部分都包含标题的自定义视图。 Normally, the previous header will be pushed away when the header below is scrolled to the top of the tableView. 通常,当下面的标题滚动到tableView的顶部时,前一个标题将被推开。

Question: Is it possible to prevent that "pushed out" behavior. 问题:是否有可能防止这种“赶出”行为。 I would like something along the line of "stacking" behavior. 我想要一些“堆叠”行为。 This is because I would like the user to have the full view of what headers are available. 这是因为我希望用户对可用的标头有完整的了解。 For example, if one scroll to the lowest cell, one will see all headers on the top of the tableView. 例如,如果滚动到最低的单元格,则将在tableView的顶部看到所有标题。

Additional Info: Please do not answer with hacks, for example, track the movement of the tableView, add the header view manually when needed, then resize the tableView. 附加信息:请不要回答黑客,例如,跟踪tableView的运动,在需要时手动添加标题视图,然后调整tableView的大小。

It's not possible without using methods like you describe. 如果不使用您描述的方法,这是不可能的。 At least not with the built-in table view. 至少不是内置表视图。

One reason is that it just doesn't scale to arbitrary content. 原因之一是它无法扩展到任意内容。 If you let section headers stack up what should happen when the entire screen is full of headers? 如果让节标题堆积起来,当整个屏幕都充满标题时会发生什么? How would the user be able to comfortably see and interact with the content under the 6th or 7th section when there is only a few pixels left to show the content because the rest of the screen is taken up by header for sections that the user is obviously not interested in. 当仅剩下几个像素来显示内容时,用户将如何舒适地观看第6或第7部分下的内容并与之交互,因为屏幕的其余部分由标题明显占据了该部分的标题占据了不感兴趣。

You probably want to rethink your UI. 您可能想重新考虑UI。 Either go with the standard section headers, make some cool light-weight tabs, a custom harmonica control or something entirely different. 要么使用标准的节标题,要么制作一些很酷的轻量级的标签,一个自定义的口琴控件或完全不同的东西。 Maybe even a hierarchical structure depending on the amount of content you want to present. 甚至可能取决于您要呈现的内容量的层次结构。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM