UITableView Creating Static Cells in Dynamic Environment

487 Views Asked by At

I have a UITableView that is currently set up to be dynamic as the cells change based on the users input. Some of the cells have Text Fields, others have switches and others have segment selectors. I am not really sure where to start here. Here is what I plan to do. Let me know if any of it is wrong. The first step (I think) would be to create the object that I want in the cell such as a UITextField or a UILabel and then add it as a subview. Then I would give it a tag.

This is where I am stuck. Because the cells get reused, the textfield would either jump to other fields and the text inside it would disappear or jump to another cell, is this right?

How would I go about doing this? I am really stuck here so thanks for any help :)

Look forward to the replies!

1

There are 1 best solutions below

0
On BEST ANSWER

You should use static cells to display cells with different elements in them and dynamic cells to display repeating contents.

You can setup the static cells with textfields, labels, switches, etc, in interface builder (or storyboard) and set each row to be displayed or hidden in your code. See this post.