views:

54

answers:

3

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 i.e. the cell should stay at 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?

A: 

What you probably need is a table's header - check tableHeaderView property in UITableView

Vladimir
I think @Alx talks about freezing a cell in some position. So that it won't scroll together with the table. Something like the freeze option in Excel - usually used for headers...
Michael Kessler
The "to a certain position" part kind of makes me think that's not the case (locking a cell to the middle of the table would look... how?) but maybe you're right.
Kalle
I am trying to have a cell at the top of the cell always remain there and not scroll down when an object is added .
Alx
A: 

I think this isn't possible because tableview is a in uiscrollview, maybe if you add the subView to your navigationController.view?

Simon
+1  A: 

You can't force a tableview cell to always remain on screen. 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. Create the view you want and then assign it to the tableview's tableHeaderView or tableFooterView property.

TechZen
i believe this would work.i would implement this as a property correct? and then create an array to add that cell to this header?
Alx
You create a UIView, either programmatically or in Interface Builder, with the textfields, buttons etc that you want to always display. Then assign that view to the `tableHeaderView`. That view is distinct from the table i.e. it is not a row of the table. You need to write custom code to populate it.
TechZen