jtbandes jtbandes - 1 year ago 105
iOS Question

Modifying the text in a static UITableView cell?

I'm using a "Static Cells" table view created in my storyboard file. However I'd like to update the text on one of these cells when a setting is changed.

I'm pushing a view controller which updates the setting. I'm trying to use a callback to change the cell's text when it's popped off the stack, but by that point the cell has apparently been recycled or reused, so the old object is off screen and no longer used in the table view.

Is there a way I can update this text, and make it permanent (so that when the cell is scrolled off screen and comes back, the new value still appears)?

Answer Source

Assuming your table view hierarchy is along the lines of:

Table View (static cells)
 - Table View Section
  - Table View Cell
    - UILabel (with the text property you want to modify)
  1. Declare an IBOutlet UILabel in your code, and wire it up in the storyboard's UILabel in the table view hierarchy above.
  2. In your callback method, set your UILabel's text property as you see fit.
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download