I have a tableview actings as a settings or preferences panel (see below). The name of the setting (for example Address) is the header of the section the setting is part of. My question is if I want to allow the user to add her own setting how should this be done? I was thinking of adding a "+" button on a toolbar and having a modal view controller pop up asking for the new setting details. My question is whether there is a way of adding the setting directly to the settings view instead of popping up a modal view controller. So pressing the "+" would expand the the view shown below with textfields for entering the details for the new setting.
+3
A:
You have two options.
You can, for example, set a flag when the "add" button is tapped and call [tableView reloadData]
.
Or, you can use these methods in UITableView
:
– insertRowsAtIndexPaths:withRowAnimation:
– deleteRowsAtIndexPaths:withRowAnimation:
– insertSections:withRowAnimation:
– deleteSections:withRowAnimation:
Of course, the latter option is more suited to what you're trying to accomplish. See the UITableView Reference for more information on the aforementioned methods.
Can Berk Güder
2010-02-24 22:12:31
Thanks, I totally forgot about insertSections!
ennuikiller
2010-02-24 22:22:07