Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial
TJ Rogers
8,758 PointsPicker View Help
I have a Login Screen with 5 Fields. Currently, all fields prompt the keyboard as the first responder, as is normal. What I would like is for 4 of these fields to prompt the keyboard as it currently stands when the text fields are clicked, but for 1 of the fields to dismiss the keyboard and show a picker view in its place.
All the picker view tutorials I have seen treat the PV as a static object that just sits on a View Controller altering a label, without the means to dismiss it, or to program it so that the PV only appears in a view when a text field is clicked.
Can anyone point me in this direction? Do I just plop a PV down on the storyboard and then dismiss it programatically in viewWillAppear or something? Then prompt it again when the text view is clicked. Will there be a conflict when the Keyboard is present and the picker view is called?
If anyone has thoughts on this or can point me to a resource I would appreciate it.
Thanks!
1 Answer
Stone Preston
42,016 PointsI havent worked with a picker view before, but this could work:
you could plop it down in your storyboard then in viewWIllAppear hide it using
self.picker.hidden = YES;
then when the text field/label/whatever you use is pressed (you could use an action for this, or a delegate method if it has one)
self.picker.hidden = NO;
if there is a conflict with the keyboard and the picker view you could dismiss it when the picker view appears then bring it back up when the picker view is hidden again I guess. Couldnt really tell you much about that