How would I use a tableView as a value selector?
So I have a series of input fields and what I want is when you select a cetian field it opens a tableview of options that you can pick from as a value for that field.
Upon selecting an option it returns to the previous View with the selected value filling that field.
This is what I do, similar to the Settings > General > International > Language table view in the iPhone/iPod.
The user can tap a row and a check mark will appear. The view is dismissed when “Done” or “Cancel” is tapped.
First, create a
UITableViewControllerthat will display your options. Have a toolbar on the top with a Cancel and Done button. Also have these properties:This view will be presented with the
presentModalViewController:animated:method so it appears from the bottom of the screen. You could present it in any other way, but it seems kind of standard across iPhone applications.Before presenting the view, set
targetandselectorso a method will be called when the user taps the “Done” button.Now, in your newly created
UITableViewController you can implement the thetableView:didSelectRowAtIndexPath:` method as:Also implement cancel and done methods for the toolbar buttons: