Parrots
Parrots

Reputation: 26882

iPhone UITextField within TableCell blanking out

In my iPhone app I have a settings page where a user can enter text into multiple TextFields. The text fields are all cells within a table. The problem I'm noticing is that when a field scrolls off the phone's screen it loses the value currently in the text field.

I notice Apple's apps always have you click on a field to edit it, which brings up a new view with just that field as a text box. Seems like pointless extra clicks, I'm hoping to find a way to allow for a table with UITextFields to preserve their values, even when they scroll of screen.

I do have an event bound to when the user presses the Next/Done button on the keyboard (didFinishEditingField:) to update a value within the table controller, but if they don't press that and the just tap inside another field that isn't triggered.

How can I make sure the values aren't blanked out when I scroll the table and fields leave the current screen?

Edit: For clarification the reason I went with the UITextFields inside of a table and cells, instead of all in one view, is because I wanted it to look like the typical settings page with the stripped background and the groups of inputs.

Upvotes: 2

Views: 1334

Answers (3)

jimiHendrix
jimiHendrix

Reputation: 169

I had the same problem, and was not dequeuing cells. Uniquely identifying the cells is confirmed to work.

Upvotes: 1

Daniel
Daniel

Reputation: 22395

The problem is that u arent reusing cells properly give all ur textfield cells unique reusable ids Check out my answer herehttp://stackoverflow.com/questions/1180490/iphone-custom-uitableviewcell-with-image-after-scroll/1180817#1180817

Upvotes: 2

Tim
Tim

Reputation: 60110

Are you reusing cells? Moreover, to create your initial cell do you use dequeueReusableCellWithIdentifier:? I've tried something similar, and it turns out that reusing cells, then adding editable fields to them, produces unexpected results.

Upvotes: 1

Related Questions