LetBulletFlies
LetBulletFlies

Reputation: 285

how to access these text fields within a UITableViewCell?

I have a screen and a UITableView within it to display some companies information. Every company's area has 1 address text field and an arrow icon followed on UI. Click the arrow icon, contacts of this company will be showed. The data includes name and telephone. These contacts are UITableViewCells as well, which belong to same section. For 2nd company, there is another section.

In every section, below these contacts cell, there is a "Edit/Save" button. user can edit or save contacts' name and telephone by clicking it.

my question is,

I can know which Edit/Save button is clicked by using (id)sender in action method, but how can I read the values of the updated contacts' name/telephone in those 2 text fields just above the button?

Thanks in advance!

the whole table view looks like this,

company1

address [arrow button]

contact's name contact's telephone [edit/save]

company2

address [arrow button] ...

Upvotes: 0

Views: 71

Answers (1)

Wain
Wain

Reputation: 119031

Your controller should be the delegate for each UITextField that is used for entering details.

Whenever any text is changed, record it straight away (into a temporary store like a dictionary, using textField:shouldChangeCharactersInRange:replacementString:). You do it immediately so you don't need to worry about completing edits at the end and so that nothing is lost if the table view is scrolled.

If the table view is scrolled and the cells are recreated you can fill in the previously entered value from the temporary store.

Now, when the save button is pressed you use the temporary store of data.

Upvotes: 1

Related Questions