I have a textField inside a tableViewCell. I recently noticed that if I enter a value in the textBox, and then scroll the cell off the screen, the value in the textbox disappears.
I have a safeguard against this. If there is no UIKeyboard present, the tableView can't scroll far enough to have to redraw the cell. However, some users don't use the done key on the keyboard to make the keyboard go away, and instead scroll the table up, breaking the program.
Is there a way to immediately store the textField string to a variable, or keep the tableView from scrolling, or make the keyboard disappear if the user tries to scroll the tableView?
I don't have a NIB file for this view, it's a programmatic tableViewController, so I can't do anything in Interface Builder with invisible custom buttons, as suggested in other questions on StackOverflow.
Are you instantiating the text field inside your cellForRowAtIndexPath:: method? If so, it may be re-instantiating each time the cell scrolls into view.
You should save a reference to the text field on your controller and reuse it in your cellForRowAtIndexPath::
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With