UITableView 部分始终保持在视图中 [英] UITableView sections to always stay within view
问题描述
我有一个包含 3 个部分的 UITableView:
I have a UITableView with 3 sections:
第 1 部分:此部分的标题标题是玩家",内容正好是包含 1-4 个玩家姓名的水平列表的 1 个单元格.
section 1: the header title of this section is "Players" and the cotent is exactly 1 cell containing a horizontal list of 1-4 players names.
第 2 部分:此部分的标题是轮次",内容是 X 个单元格,每个单元格包含 X 轮每个玩家得分的水平列表.
section 2: the header title of this section is "Rounds" and the content is X cells each containing a horizontal list of each respective players score for round X.
第 3 部分:这部分的标题是总分",内容正好是 1 个包含每个玩家回合分数总和的单元格.
section 3: the header title of this section is "Totals" and the content is exactly 1 cell containing the sum of each player's round scores.
现在,所有这些部分都随着第 2 部分的展开而滚动,但我希望始终将第 1 部分保留在屏幕顶部,并将第 3 部分放在第 2 部分的正下方,直到它向下扩展到屏幕底部屏幕,然后停在那里.
Right now, all these sections scroll as section 2 expands with new rounds, but I want to always keep section 1 at the top of the screen, and have section 3 right below section 2, until it expands down to the bottom of the screen and then stop and stay there.
我想我可以在 UIView 中使用 3 个单独的表格视图来完成此操作,但这似乎有点复杂,而且我的第 3 部分不会停留在第 2 部分的正下方,直到它扩展到屏幕底部;它总是在底部......
I guess I could do this with 3 separate table views inside a UIView but that seems kind of convoluted and I section 3 wouldn't stay right below section 2 until it expanded to the bottom of the screen; it would just always be at the bottom...
有没有办法让表格部分/行始终可见,而其他部分仍然可以滚动?
Is there a way to keep a table section/row always visible, and have the others still scrollable?
推荐答案
如您所讨论的那样使用 3 个 UITableViews,并在每次向 tableView 2 添加单元格时将第三个 tableview 的位置动画化以将其向下移动,直到它到达然后将其留在屏幕底部.(此外,您还需要在向 tableView 2 添加元素时扩展它的高度.)
Use 3 UITableViews as you discussed, and just animate the position of the Third tableview to move it down each time you add a cell to tableView 2, until it reaches the bottom of the screen then just leave it there. (Also you will need to expand the height of tableView 2 as you add elements to it.)
否则,就像 Cyrille 所说的,没有办法只用一个 tableview 来实现.
Otherwise, like Cyrille said, there is no way to implement that with one tableview only.
这篇关于UITableView 部分始终保持在视图中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!