Reputation: 225
I have a view with 8 textfields. I want each textfield to be associated with a pickerview which will have different items. This pickerview should populate each text field.
When I click on the textfield it should show the pickerview and the items associated with it and when I select the item for that textfield it should dismiss the pickerview. Then again when I click on next textfield it should show the pickerview with the items for that text field and so on...
Is it possible to do so? I am new to xcode. Any help is much appreciated. Thank you.
Upvotes: 2
Views: 1764
Reputation: 3158
Absolutely possible. Here's my best recommendation:
NSArray
.IBAction
from each textfield to a function within the view controller's code.UIPickerView
with the contents of the array corresponding to the current picker.As I here you're new to Xcode, let me know if you need any additional explanation.
BTW, here is the class reference for UIPickerView
:
http://developer.apple.com/library/ios/#documentation/uikit/reference/UIPickerView_Class/Reference/UIPickerView.html
UPDATE: In the function that is triggered when the textfield is tapped, allocate and instantiate the picker. Then, add it to your view. Afterwards, simply remove it from the view when the user has finalized his selection.
Upvotes: 2