Is there a standard way to set up a table to allow editing-in-place, kind of like this:
I only need editable text at the moment, but I might need UISwitches or UISliders in the future.
Is there a standard way to set up a table to allow editing-in-place, kind of like this:
I only need editable text at the moment, but I might need UISwitches or UISliders in the future.
Edit in-place using a "Content: Static Cells" and make it look like a default styled UITableviewCell.
The looks pretty equal, aren't they?
Now, do the IBoutlet stuff.
Yep. Just add a
UITextField
, with itsfont
andtextColor
set to appropriate values, as subviews of the table cell'scontentView
. You probably want to give the field atag
as well, so that you can easily grab a reference to it using thecontentView
's-viewWithTag:
method.With short forms you can get away with keeping an array of cells, one for each field, and handing them off to the table view without going through the
-dequeueReusableCellWithIdentifier:
mechanism, but if you've got a lot of stuff to enter then it gets more complicated. In that case, you probably want to assign a different reuse identifier to each type of cell—one for text-field cells, one for switch cells, one for slider cells, etc. Once you've dequeued or created the row's cell, you'd then grab its control from the content view (as above) and set its value from wherever you've stored that.