views:

23

answers:

1

Hello,

I have a ViewController with a number of fields. One of these fields is a text box, I want the user to be able to tap on the text field and be presented with a table view where they can select from a pre-defined list and their selection will then be filled in the text box. Can anyone point me in the direction of a tutorial or some sample code would be great.

Thanks Stephen

A: 

Is this view controller in a Navigation Controller? if so you can simply push a new UITableViewController onto the navigation controller and do it that way. If you are not using a navigation controller, implementing a pickerview would work better than trying to present a tableview modally if it is just a selection from a predefined set of items.

That being said, if you do want the table view, and don't want to add a navigation controller, the way to do it is to presentModalViewController:viewController and then when the user selects a row, save his selection and dismiss the modal controller and update your textfield.

Jesse Naugher
Jesse, thanks for getting back to me. I'd actually prefer to use a UIPicker rather than a UITableView, but having a bit of hassle. An App similar to the one I'm developing is using tableViews that's why I was looking at doing it that way. I think I'll stay away from the table view. Thanks for your feedback. Stephen
Stephen