Reputation: 2777
I have a custom UITableView
with all kinds of cells. I build this tableview by creating for each section a subClass of UITableViewCell
. You can see my form over here. Like you can see is, I have textfields, textViews and switches. At the bottom of my form (not on the screenshot) I have a save button.
I made a Person
class with the following properties.
In my viewDidLoad
I load up the tableView
with data from my persons object. But now I want when a users changes some fields and it pushed on the save button, all the fields are saved into the persons object.
Problems I have
Anybody got an idea how I can do this ? Kind regards
Upvotes: 1
Views: 729
Reputation: 4018
UITableViewCell uses a caching mechanism where it's contents are reloaded when it is scrolled off the screen and back on. What this means is, by scrolling the cell out of the screen bounds and then scrolling it back onto the screen, you are redrawing the cell.
The solution is to use a data source in your table view controller:
tableView:cellForRowAtIndexPath:
method.Hope that helps!
Upvotes: 2
Reputation: 4490
its because you are not updating the array from which you are populating your cell, now when you scroll your tableView, and then scroll up again, your cells are created again and theses cells get there textfield's text from the array which still has old values. try updating your array from which you populate your tableview in the textfield's didEndEditing delegate method.
Upvotes: 0