[英]iPhone: "Locking" a Cell to the Top of TableView
I am trying to have a cell at the top of the table always remain there and not scroll down when an object is added ie the cell should stay at indexpath.row==0
.我试图让表格顶部的单元格始终保留在那里,并且在添加对象时不向下滚动,即单元格应保留在
indexpath.row==0
。 Is it possible to lock a cell to a certain position in a table?是否可以将单元格锁定到表格中的某个位置? If so, how would this be implemented?
如果是这样,这将如何实施?
EDIT编辑
If i made a different section for this cell that would work wouldnt it?如果我为这个单元格制作了一个不同的部分,它会起作用吗?
You can't force a tableview cell to always remain on screen.您不能强制 tableview 单元格始终保留在屏幕上。 That would defeat the purpose of having a table in the first place.
这将破坏首先拥有一张桌子的目的。
Instead, if you need something always displayed in a tableview, you put it in either a the table's header or footer views.相反,如果您需要始终在 tableview 中显示某些内容,请将其放在 table 的页眉或页脚视图中。 Create the view you want and then assign it to the tableview's
tableHeaderView
or tableFooterView
property.创建您想要的视图,然后将其分配给
tableFooterView
的tableHeaderView
或tableFooterView
属性。
您可能需要的是表格的标题 - 检查 UITableView 中的tableHeaderView
属性
我认为这是不可能的,因为 tableview 是 uiscrollview 中的一个,也许如果您将 subView 添加到您的 navigationController.view 中?
我发现这篇博文是一个有用的技巧,可以在UITableView
顶部放置静态内容并允许它对触摸做出反应。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.